iawia002/lux · error
could not find video in page
Error message
could not find video in page
What it means
bilibili.extractFestival handles festival/activity pages. It matches the whole script tag containing window.__INITIAL_STATE__ and this error fires when the outer script regex matched but the capture group is absent (len(matches[0]) < 2), i.e. the festival page has no extractable video state. It is distinct from the sibling ErrURLParseFailed check one line above, which fires when no script matched at all.
Source
Thrown at extractors/bilibili/bilibili.go:205
html, `window.__INITIAL_STATE__=(.+?);\(function`,
)
if multiPageDataString == nil {
return &data, errors.New("this page has no playlist")
}
err := json.Unmarshal([]byte(multiPageDataString[1]), &data)
if err != nil {
return nil, errors.WithStack(err)
}
return &data, nil
}
func extractFestival(url, html string, extractOption extractors.Options) ([]*extractors.Data, error) {
matches := utils.MatchAll(html, "<\\s*script[^>]*>\\s*window\\.__INITIAL_STATE__=([\\s\\S]*?);\\s?\\(function[\\s\\S]*?<\\/\\s*script\\s*>")
if len(matches) < 1 {
return nil, errors.WithStack(extractors.ErrURLParseFailed)
}
if len(matches[0]) < 2 {
return nil, errors.New("could not find video in page")
}
var festivalData festival
err := json.Unmarshal([]byte(matches[0][1]), &festivalData)
if err != nil {
return nil, errors.WithStack(err)
}
options := bilibiliOptions{
url: url,
html: html,
aid: festivalData.VideoInfo.Aid,
bvid: festivalData.VideoInfo.BVid,
cid: festivalData.VideoInfo.Cid,
page: 0,
}
return []*extractors.Data{bilibiliDownload(options, extractOption)}, nilView on GitHub (pinned to dd00f6d258)
Solutions
- Confirm the festival URL still shows its video in an incognito browser.
- If the event ended, locate the underlying av/BV id in the page and extract that video URL directly.
- Retry with a cookie (-c) to bypass risk control.
- If the page format changed, update the extractFestival script regex.
Example fix
// before $ lux "https://www.bilibili.com/festival/2022bnj?bvid=BV1er411b7mJ" // after — extract the underlying video id directly $ lux "https://www.bilibili.com/video/BV1er411b7mJ"
Defensive patterns
Strategy: try-catch
Type guard
func isFestivalVideoMissing(err error) bool {
return err != nil && strings.Contains(err.Error(), "could not find video in page")
} Try / catch
Catch and, when this specific message appears, retry once with the underlying av/BV video URL extracted from the festival page; otherwise surface the error with the original festival link for manual triage.
Prevention
- Treat festival links as perishable — events end and pages redirect
- Pre-resolve festival URLs to their concrete video ids when archiving content
- Pass a cookie for risk control when scraping bilibili at scale
When it happens
Trigger: A /festival/ URL whose activity ended and now redirects elsewhere; a festival template without the __INITIAL_STATE__ script payload; a risk-control page served instead of the festival DOM.
Common situations: Expired seasonal event links (the most common case); Bilibili template changes; scraping from flagged IPs.
Related errors
- this page has no playlist
- Could not extract media URL from page
- Could not extract media name from page
- ErrURLParseFailed
- ErrURLQueryParamsParseFailed
AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15).
Data as JSON: /api/errors/422a8008b283946a.
Report an issue: GitHub.