ytdl-org/youtube-dl · error · ExtractorError

Did not get a media key

Error message

Did not get a media key

What it means

Raised by the HotNewHipHop extractor when the AJAX endpoint /ajax/media/getActions/ (POSTed with mediaType=s, mediaId=<id>) returns JSON without a 'mediaKey'. Not marked expected, so youtube-dl reports it as a bug-worthy failure even though it usually reflects server-side refusal.

Source

Thrown at youtube_dl/extractor/hotnewhiphop.py:48

            r'data-path="(.*?)"', webpage, 'video URL', default=None)

        if video_url_base64 is None:
            video_url = self._search_regex(
                r'"contentUrl" content="(.*?)"', webpage, 'content URL')
            return self.url_result(video_url, ie='Youtube')

        reqdata = urlencode_postdata([
            ('mediaType', 's'),
            ('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

  1. Confirm the video page still exists and plays at hotnewhiphop.com
  2. Update youtube-dl/yt-dlp — the HNHH extractor has needed multiple rewrites
  3. Try again later in case of rate limiting
  4. Extract the final mp4 URL from browser devtools and download it directly
Defensive patterns

Strategy: try-catch

Validate before calling

import requests
r = requests.post('http://www.hotnewhiphop.com/ajax/media/getActions/',
                  data={'mediaType': 's', 'mediaId': mid},
                  headers={'Content-Type': 'application/x-www-form-urlencoded'})
if 'mediaKey' not in r.json():
    print('HNHH will fail: no mediaKey in getActions response')

Type guard

def hnhh_media_ready(mkd):
    return isinstance(mkd, dict) and 'mediaKey' in mkd

Try / catch

try:
    ydl.extract_info(url)
except DownloadError as e:
    if 'media key' in str(e):
        retry_once_then_report(url)  # transient rate limit vs site change
    else:
        raise

Prevention

When it happens

Trigger: The getActions endpoint responds with an error/empty object: dead mediaId, site-side rate limiting, or the endpoint now requiring session cookies/CSRF the extractor does not send.

Common situations: Removed or migrated HNHH videos, hotnewhiphop.com changing its AJAX API (the site has been rebuilt more than once), or bot detection returning an error payload.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/32c3d6730f34f8f3. Report an issue: GitHub.