iawia002/lux · error
can not found media
Error message
can not found media
What it means
Thrown by the PornHub extractor after it parses the page's mediaDefinitions array: it scans for an entry with Format == "mp4" and fails to find one. PornHub delivers videos as a list of media definitions in different formats/qualities; if none is labeled mp4, the extractor has no download URL it can use.
Source
Thrown at extractors/pornhub/pornhub.go:136
if str, err := value.ToString(); err != nil {
return nil, errors.WithStack(err)
} else {
if err := json.Unmarshal([]byte(str), &mediaDefinitions); err != nil {
return nil, errors.WithStack(err)
}
}
var mp4MediaDefinition *MediaDefinition
for _, mediaDefinition := range mediaDefinitions {
if mediaDefinition.Format == "mp4" {
mp4MediaDefinition = &mediaDefinition
}
}
if mp4MediaDefinition == nil {
return nil, errors.New("can not found media")
}
resApi, err := request.Get(mp4MediaDefinition.VideoURL, mp4MediaDefinition.VideoURL, map[string]string{
"Cookie": strings.Join(cookiesArr, "; "),
})
if err != nil {
return nil, errors.WithStack(err)
}
pornhubs := make([]pornhubData, 0)
if err := json.Unmarshal([]byte(resApi), &pornhubs); err != nil {
return nil, errors.WithStack(err)
}
streams := make(map[string]*extractors.Stream, len(pornhubs))
for _, data := range pornhubs {View on GitHub (pinned to dd00f6d258)
Solutions
- Pass a logged-in browser cookie through Options.Cookie so PornHub serves the real player page with mp4 definitions
- Verify the video URL plays in a private browser window without login; if it shows a paywall/age wall, the extractor cannot access it either
- Check whether the fetched HTML actually contains mediaDefinitions JSON (log the page) to distinguish 'no mp4 format' from 'wrong page served'
- Update the extractor to also accept other formats (e.g. hls) if PornHub shifted delivery away from mp4
Example fix
// before
options := extractors.Options{} // no cookie
_, err := pornhub.Extract(url, options)
// after
options := extractors.Options{
Cookie: "ua=...; accessAgeDisclaimer=1; il=v; ...", // from a logged-in browser session
}
_, err := pornhub.Extract(url, options) Defensive patterns
Strategy: try-catch
Try / catch
_, err := pornhub.Extract(url, opts)
if err != nil {
if strings.Contains(err.Error(), "can not found media") {
// likely age/premium wall: retry once with a logged-in cookie, else skip
}
return err
} Prevention
- Always pass a fresh logged-in cookie via Options.Cookie for age-restricted content
- Filter premium URLs out of batch input unless you hold a VIP session
- Re-verify cookie validity periodically; expired sessions reproduce this error
When it happens
Trigger: Calling Extract on a premium or age-restricted video whose mp4 definitions only appear for logged-in users, a region-blocked video, or a page where anti-bot/consent markup replaced the real player so mediaDefinitions is empty or only contains other formats (e.g. hls).
Common situations: No session cookie passed via extractors.Options.Cookie so the consent/age wall is served instead of the video page; premium content accessed without a paid account; the video was removed and the page no longer embeds definitions.
Related errors
AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15).
Data as JSON: /api/errors/7aa57f8f4f9ee09c.
Report an issue: GitHub.