iawia002/lux · error
can't get video size
Error message
can't get video size
What it means
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.
Source
Thrown at extractors/reddit/reddit.go:149
},
Size: size,
},
},
URL: url,
},
}, nil
} else if utils.MatchOneOf(html, `https:\/\/preview\.redd\.it\/.*gif`) != nil {
gifURL := utils.MatchOneOf(html, `https:\/\/preview\.redd\.it\/.*?\.gif\?format=mp4.*?"`)[0]
if gifURL == "" {
return nil, errors.New("can't match gif content downloadable url")
}
gifURL = strings.ReplaceAll(gifURL, "&", "&")
gifURL = strings.ReplaceAll(gifURL, "\"", "")
size, err := request.Size(gifURL, "reddit.com")
if err != nil {
return nil, errors.New("can't get video size")
}
streams := map[string]*extractors.Stream{
"default": {
Parts: []*extractors.Part{
{
URL: gifURL,
Size: size,
Ext: "mp4",
},
},
Size: size,
},
}
return []*extractors.Data{
{
Site: siteName,
Title: title,View on GitHub (pinned to dd00f6d258)
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
Example fix
// before
size, err := request.Size(gifURL, "reddit.com")
if err != nil {
return nil, errors.New("can't get video size")
}
// after (retry once with a fresh page fetch before giving up)
size, err := request.Size(gifURL, "https://www.reddit.com")
if err != nil {
if size2, err2 := request.Size(gifURL, "https://www.reddit.com"); err2 == nil {
size = size2
} else {
return nil, errors.New("can't get video size")
}
} Defensive patterns
Strategy: retry
Try / catch
var d *extractors.Data
for attempt := 0; attempt < 2; attempt++ {
var err error
d, err = reddit.Extract(url, opts)
if err == nil || !strings.Contains(err.Error(), "can't get video size") {
break
}
time.Sleep(time.Duration(attempt+1) * 2 * time.Second) // expired URL / throttle: fresh pass
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- can't match mp4 content downloadable url
- can't match gif content downloadable url
- Content-Length is not present
- failed to send HTTP request to the Instagram: %v
AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15).
Data as JSON: /api/errors/db459557e553e83f.
Report an issue: GitHub.