{"record":{"id":"db459557e553e83f","repo":"iawia002/lux","slug":"can-t-get-video-size","errorCode":null,"errorMessage":"can't get video size","messagePattern":"can't get video size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extractors/reddit/reddit.go","lineNumber":149,"sourceCode":"\t\t\t\t\t\t},\n\t\t\t\t\t\tSize: size,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tURL: url,\n\t\t\t},\n\t\t}, nil\n\t} else if utils.MatchOneOf(html, `https:\\/\\/preview\\.redd\\.it\\/.*gif`) != nil {\n\t\tgifURL := utils.MatchOneOf(html, `https:\\/\\/preview\\.redd\\.it\\/.*?\\.gif\\?format=mp4.*?\"`)[0]\n\t\tif gifURL == \"\" {\n\t\t\treturn nil, errors.New(\"can't match gif content downloadable url\")\n\t\t}\n\n\t\tgifURL = strings.ReplaceAll(gifURL, \"&amp;\", \"&\")\n\t\tgifURL = strings.ReplaceAll(gifURL, \"\\\"\", \"\")\n\n\t\tsize, err := request.Size(gifURL, \"reddit.com\")\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"can't get video size\")\n\t\t}\n\n\t\tstreams := map[string]*extractors.Stream{\n\t\t\t\"default\": {\n\t\t\t\tParts: []*extractors.Part{\n\t\t\t\t\t{\n\t\t\t\t\t\tURL:  gifURL,\n\t\t\t\t\t\tSize: size,\n\t\t\t\t\t\tExt:  \"mp4\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tSize: size,\n\t\t\t},\n\t\t}\n\t\treturn []*extractors.Data{\n\t\t\t{\n\t\t\t\tSite:    siteName,\n\t\t\t\tTitle:   title,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/iawia002/lux/blob/dd00f6d258d80b6684a0b9402d7124e5c18ef42f/extractors/reddit/reddit.go#L131-L167","documentation":"In the Reddit GIF branch, after a gif→mp4 URL was successfully extracted from the HTML, request.Size(gifURL, \"reddit.com\") failed and the extractor wraps it as 'can't get video size'. The real failure is the underlying HTTP exchange for the media URL: connection error, non-200 status, or a rejected HEAD-style probe.","triggerScenarios":"The extracted preview.redd.it URL is stale or signed and expired by the time Size() runs; the media CDN rejects the bare 'reddit.com' referer; transient network failure or 429 rate limiting during the headers request.","commonSituations":"Delay between fetching the page and requesting media (signed URLs expire); aggressive scraping triggering Reddit throttling; flaky networks where the HTML fetch succeeded but the second request failed.","solutions":["Re-run the extraction so a freshly signed media URL is fetched and sized in the same pass","If it fails consistently, fetch the gifURL manually with referer 'reddit.com' to see the status code (403 = expired signature, 429 = throttled)","Back off and retry later if Reddit is rate limiting your IP","Patch the extractor to use the full 'https://www.reddit.com' referer if the bare domain is rejected"],"exampleFix":"// before\nsize, err := request.Size(gifURL, \"reddit.com\")\nif err != nil {\n    return nil, errors.New(\"can't get video size\")\n}\n\n// after (retry once with a fresh page fetch before giving up)\nsize, err := request.Size(gifURL, \"https://www.reddit.com\")\nif err != nil {\n    if size2, err2 := request.Size(gifURL, \"https://www.reddit.com\"); err2 == nil {\n        size = size2\n    } else {\n        return nil, errors.New(\"can't get video size\")\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var d *extractors.Data\nfor attempt := 0; attempt < 2; attempt++ {\n    var err error\n    d, err = reddit.Extract(url, opts)\n    if err == nil || !strings.Contains(err.Error(), \"can't get video size\") {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 2 * time.Second) // expired URL / throttle: fresh pass\n}","preventionTips":["Extract and download in the same pass — Reddit media URLs expire quickly","Rate-limit your requests to avoid 429s that surface as size failures","On repeated failure, probe the media URL manually to read the status code"],"tags":["reddit","http","expired-url","rate-limit"],"backgroundTag":null,"analyzedSha":"dd00f6d258d80b6684a0b9402d7124e5c18ef42f","analyzedAt":"2026-08-15T16:57:31.080Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}