iawia002/lux · error
can't match gif content downloadable url
Error message
can't match gif content downloadable url
What it means
In the Reddit extractor's GIF branch: the page matched 'preview\.redd\.it/.*gif', so it captures the full 'https://preview.redd.it/...gif?format=mp4...' URL from the HTML. If that capture comes back empty, extraction fails. Like the mp4 branch, the guard indexes [0] directly — a nil MatchOneOf panics before this check, so the error only fires for an empty-string capture.
Source
Thrown at extractors/reddit/reddit.go:141
Streams: map[string]*extractors.Stream{
"default": {
Parts: []*extractors.Part{
{
URL: imgURL,
Size: size,
Ext: "jpg",
},
},
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",
},View on GitHub (pinned to dd00f6d258)
Solutions
- Fetch the post HTML and search for 'preview.redd.it' to see the actual URL format now served
- Update the gif capture regex in extractors/reddit/reddit.go to match the current preview URL shape
- Nil-guard the MatchOneOf result before indexing [0] so markup changes produce this error instead of a panic
- Retry once — Reddit serves different markup variants across requests
Example fix
// before
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")
}
// after
gifMatch := utils.MatchOneOf(html, `https:\/\/preview\.redd\.it\/.*?\.gif\?format=mp4.*?"`)
if gifMatch == nil || gifMatch[0] == "" {
return nil, errors.New("can't match gif content downloadable url")
}
gifURL := gifMatch[0] Defensive patterns
Strategy: try-catch
Try / catch
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("reddit extractor panicked (gif branch markup change): %v", r)
}
}()
_, err = reddit.Extract(url, opts)
if err != nil && strings.Contains(err.Error(), "can't match gif content") {
// preview.redd.it URL shape changed: skip and report
} Prevention
- Wrap reddit extraction in recover — indexing MatchOneOf[0] without a nil check can panic
- Retry once on this error: Reddit serves markup variants
- Track preview.redd.it URL format changes in your monitoring
When it happens
Trigger: Reddit changed the preview URL shape for gif posts (different host like v.redd.it or i.redd.it, dropped '?format=mp4', changed query ordering) so `https:\/\/preview\.redd\.it\/.*?\.gif\?format=mp4.*?"` no longer captures content.
Common situations: Site markup drift on Reddit's preview CDN links; posts converted from gif to native video between the og:video check and the gif branch; HTML-escaped URLs (&) altering the match.
Related errors
- can't match mp4 content downloadable url
- ErrURLParseFailed
- Could not read page data
- this page has no playlist
- could not find video in page
AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15).
Data as JSON: /api/errors/168677cc2e9198e4.
Report an issue: GitHub.