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.

Solutions

  1. Fetch the post HTML and search for 'preview.redd.it' to see the actual URL format now served
  2. Update the gif capture regex in extractors/reddit/reddit.go to match the current preview URL shape
  3. Nil-guard the MatchOneOf result before indexing [0] so markup changes produce this error instead of a panic
  4. 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

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


AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15). Data as JSON: /api/errors/168677cc2e9198e4. Report an issue: GitHub.

Appendix: 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)