{"record":{"id":"40b65b65e78cc387","repo":"iawia002/lux","slug":"could-not-extract-media-name-from-page","errorCode":null,"errorMessage":"Could not extract media name from page","messagePattern":"Could not extract media name from page","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extractors/bitchute/bitchute.go","lineNumber":73,"sourceCode":"\tb, err := io.ReadAll(reader)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\t// There is also an API that provides meta data\n\t// POST https://api.bitchute.com/api/beta9/video {\"video_id\": <video_id>}\n\thtml := string(b)\n\tregMediaURL := regexp.MustCompile(`media_url\\s*=\\s*['|\"](https:\\/\\/[^.]+\\.bitchute\\.com\\/.*\\.mp4)`)\n\tmatchMediaURL := regMediaURL.FindStringSubmatch(html)\n\tif len(matchMediaURL) < 2 {\n\t\treturn nil, errors.New(\"Could not extract media URL from page\")\n\t}\n\tmediaURL := matchMediaURL[1]\n\n\tregVideoName := regexp.MustCompile(`(?m)video_name\\s*=\\s*[\"|']\\\\?\"?(.*)[\"|'];?$`)\n\tmatchVideoName := regVideoName.FindStringSubmatch(html)\n\tif len(matchVideoName) < 2 {\n\t\treturn nil, errors.New(\"Could not extract media name from page\")\n\t}\n\tvideoName := strings.ReplaceAll(matchVideoName[1], `\\\"`, \"\")\n\n\tstreams := make(map[string]*extractors.Stream, 1)\n\tsize, err := request.Size(mediaURL, u)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\tstreams[\"Default\"] = &extractors.Stream{\n\t\tParts: []*extractors.Part{\n\t\t\t{\n\t\t\t\tURL:  mediaURL,\n\t\t\t\tSize: size,\n\t\t\t\tExt:  \"mp4\",\n\t\t\t},\n\t\t},\n\t\tSize:    size,\n\t\tQuality: \"Default\",","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/iawia002/lux/blob/dd00f6d258d80b6684a0b9402d7124e5c18ef42f/extractors/bitchute/bitchute.go#L55-L91","documentation":"Companion check on the same embed HTML: the extractor greps for video_name = \"...\" to title the stream. Thrown when that assignment is missing, usually for the same reasons the media URL fails (challenge page or template change). Note the regex's [\"|'] character class also matches a literal pipe, which is a latent bug for titles containing |.","triggerScenarios":"An anti-bot page that still exposes media_url but not video_name; a template migration renaming the variable; titles whose quoting does not fit the [\"|'] class or the optional backslash-quote prefix.","commonSituations":"Same contexts as the media-URL failure; videos with unusual titles; long-running scrapers after a BitChute update.","solutions":["Triage exactly as for 'Could not extract media URL from page': verify the embed page in a browser and retry with a clean session.","Fetch the title from the beta9 video API (POST https://api.bitchute.com/api/beta9/video) instead of the embed HTML.","Tighten the regex — replace the buggy [\"|'] class with ('|') style alternation and re-test."],"exampleFix":"// before\nregVideoName := regexp.MustCompile(`(?m)video_name\\s*=\\s*[\"|']\\\\?\"?(.*)[\"|'];$`)\n// after — explicit quote alternation, no literal pipe\nregVideoName := regexp.MustCompile(`(?m)video_name\\s*=\\s*('([^']*)'|\"([^\"]*)\")`)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isMediaNameMissing(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"Could not extract media name\")\n}","tryCatchPattern":"Catch and substitute a default title (the name is only used for the output file name) — e.g. fall back to the video id — then continue. Re-raise any other error.","preventionTips":["Treat title extraction as best-effort: never let a naming miss block a download","Prefer structured metadata (beta9 API) over scraping the embed HTML","When editing the regex, remember [\"|'] also matches a literal pipe character"],"tags":["bitchute","scraping","regex","metadata"],"backgroundTag":null,"analyzedSha":"dd00f6d258d80b6684a0b9402d7124e5c18ef42f","analyzedAt":"2026-08-15T16:57:31.080Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}