ytdl-org/youtube-dl · error · ExtractorError
Redirect failed
Error message
Redirect failed
What it means
Raised by the HotNewHipHop extractor after resolving the base64-decoded redirect URL via a HEAD request: the final URL still ends in .html, meaning the CDN bounced the request back to a player/error page instead of the media file.
Source
Thrown at youtube_dl/extractor/hotnewhiphop.py:57
('mediaId', video_id),
])
r = sanitized_Request(
'http://www.hotnewhiphop.com/ajax/media/getActions/', data=reqdata)
r.add_header('Content-Type', 'application/x-www-form-urlencoded')
mkd = self._download_json(
r, video_id, note='Requesting media key',
errnote='Could not download media key')
if 'mediaKey' not in mkd:
raise ExtractorError('Did not get a media key')
redirect_url = compat_b64decode(video_url_base64).decode('utf-8')
redirect_req = HEADRequest(redirect_url)
req = self._request_webpage(
redirect_req, video_id,
note='Resolving final URL', errnote='Could not resolve final URL')
video_url = req.geturl()
if video_url.endswith('.html'):
raise ExtractorError('Redirect failed')
video_title = self._og_search_title(webpage).strip()
return {
'id': video_id,
'url': video_url,
'title': video_title,
'thumbnail': self._og_search_thumbnail(webpage),
}
View on GitHub (pinned to 956b8c5855)
Solutions
- Retry with a fresh page fetch so the base64 media URL is newly generated
- Update youtube-dl/yt-dlp for current HNHH infrastructure
- Grab the real media URL from devtools (Network tab, filter by media) and download directly
- Check whether the track plays in a browser at all
Defensive patterns
Strategy: try-catch
Validate before calling
import requests
final = requests.head(redirect_url, allow_redirects=True).url
if final.endswith('.html'):
print('Redirect bounced to an HTML page — media link dead or hotlink-protected') Type guard
def redirect_is_media(final_url):
return not final_url.lower().endswith(('.html', '.htm')) Try / catch
try:
ydl.extract_info(url)
except DownloadError as e:
if 'Redirect failed' in str(e):
refetch_fresh_page_and_retry(url) # base64 media URL likely expired
else:
raise Prevention
- Always re-fetch the HNHH page immediately before extraction so the base64 URL is fresh
- Extract the real media URL from devtools as a fallback
- Treat .html redirects as expired/protected links, not network errors
When it happens
Trigger: The HEAD redirect from the resolved media URL lands on an .html page — typically the site's generic player or an error page because the media link expired, is geo-fenced, or requires the session that the browser had.
Common situations: Expired signed media URLs, hotlink protection keyed to browser cookies/referer, or HNHH infra changes after one of the site's redesigns.
Related errors
- Did not get a media key
- Redirect loop: %s
- this song has been offline because of copyright issues
- Invalid path
- Unauthorized user "%s"
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/befc86fb9b084eac.
Report an issue: GitHub.