{"record":{"id":"eef773062c91a12f","repo":"iawia002/lux","slug":"can-t-match-mp4-content-downloadable-url","errorCode":null,"errorMessage":"can't match mp4 content downloadable url","messagePattern":"can't match mp4 content downloadable url","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extractors/reddit/reddit.go","lineNumber":55,"sourceCode":"func New() extractors.Extractor {\n\treturn &extractor{}\n}\n\nfunc (e *extractor) Extract(url string, option extractors.Options) ([]*extractors.Data, error) {\n\thtml, err := request.Get(url, referer, nil)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\t// set thread number to 1 manually to avoid http 412 error\n\toption.ThreadNumber = 1\n\n\ttitle := utils.MatchOneOf(html, `<title>(.+?)<\\/title>`)[1]\n\n\tif utils.MatchOneOf(html, `meta property=\"og:video\" content=.*HLSPlaylist`) != nil {\n\t\tmp4URL := utils.MatchOneOf(html, `https://v.redd.it/(.+?)/HLSPlaylist`)[1]\n\t\tif mp4URL == \"\" {\n\t\t\treturn nil, errors.New(\"can't match mp4 content downloadable url\")\n\t\t}\n\n\t\taudioURL := fmt.Sprintf(\"%s%s%s\", redditMP4API, mp4URL, audioURLPart)\n\t\tsize, err := request.Size(audioURL, referer)\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\t\taudioPart := &extractors.Part{\n\t\t\tURL:  audioURL,\n\t\t\tSize: size,\n\t\t\tExt:  \"mp3\",\n\t\t}\n\n\t\tstreams := make(map[string]*extractors.Stream, len(resMap))\n\t\tfor res, urlParts := range resMap {\n\t\t\tresURL := fmt.Sprintf(\"%s%s%s\", redditMP4API, mp4URL, urlParts)\n\t\t\tsize, err := request.Size(resURL, referer)\n\t\t\tif err != nil {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/iawia002/lux/blob/dd00f6d258d80b6684a0b9402d7124e5c18ef42f/extractors/reddit/reddit.go#L37-L73","documentation":"In the Reddit extractor's HLS branch: the page's og:video meta tag matched 'HLSPlaylist', so it tries to capture the video id from 'https://v.redd.it/(.+?)/HLSPlaylist'. If the captured group comes back empty, the extractor cannot build the audio URL (redditMP4API + id + audioURLPart) and fails. Note the guard is weak: if the second MatchOneOf returns nil, indexing [1] panics before this check ever runs — the error only covers the empty-capture case.","triggerScenarios":"Reddit changed how v.redd.it HLS URLs appear in the og:video meta (different host, path shape, or escaping), or the post is an embed/crosspost whose og:video advertises HLS but the v.redd.it pattern does not appear in the page HTML.","commonSituations":"Reddit markup changes after the regexes were written; audio-less HLS posts where the og:video content is generated by JS and differs in the server-rendered HTML lux fetches.","solutions":["Fetch the URL manually and inspect the og:video meta tag to see the actual URL shape being served","Update the `https://v.redd.it/(.+?)/HLSPlaylist` regex in extractors/reddit/reddit.go to match the current markup","If the MatchOneOf can return nil, guard it before indexing [1] to convert a potential panic into this error","Retry the extraction — Reddit A/B-tests markup, so a fresh fetch may serve the old shape"],"exampleFix":"// before\nmp4URL := utils.MatchOneOf(html, `https://v.redd.it/(.+?)/HLSPlaylist`)[1]\nif mp4URL == \"\" {\n    return nil, errors.New(\"can't match mp4 content downloadable url\")\n}\n\n// after (avoid panic on nil match, same error)\nmp4Match := utils.MatchOneOf(html, `https://v.redd.it/(.+?)/HLSPlaylist`)\nif mp4Match == nil || mp4Match[1] == \"\" {\n    return nil, errors.New(\"can't match mp4 content downloadable url\")\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"reddit extractor panicked (likely markup change): %v\", r)\n    }\n}()\n_, err = reddit.Extract(url, opts)\nif err != nil && strings.Contains(err.Error(), \"can't match mp4 content\") {\n    // Reddit markup drift: report upstream, skip URL\n}","preventionTips":["Guard reddit.Extract calls with recover: the nil-index path can panic before this error fires","Pin to known-good URL shapes (reddit.com/r/.../comments/...) rather than share links","Watch for og:video markup drift after Reddit deploys changes"],"tags":["reddit","regex","html-parsing","index-out-of-range"],"backgroundTag":null,"analyzedSha":"dd00f6d258d80b6684a0b9402d7124e5c18ef42f","analyzedAt":"2026-08-15T16:57:31.080Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}