{"record":{"id":"32c3d6730f34f8f3","repo":"ytdl-org/youtube-dl","slug":"did-not-get-a-media-key","errorCode":null,"errorMessage":"Did not get a media key","messagePattern":"Did not get a media key","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/hotnewhiphop.py","lineNumber":48,"sourceCode":"            r'data-path=\"(.*?)\"', webpage, 'video URL', default=None)\n\n        if video_url_base64 is None:\n            video_url = self._search_regex(\n                r'\"contentUrl\" content=\"(.*?)\"', webpage, 'content URL')\n            return self.url_result(video_url, ie='Youtube')\n\n        reqdata = urlencode_postdata([\n            ('mediaType', 's'),\n            ('mediaId', video_id),\n        ])\n        r = sanitized_Request(\n            'http://www.hotnewhiphop.com/ajax/media/getActions/', data=reqdata)\n        r.add_header('Content-Type', 'application/x-www-form-urlencoded')\n        mkd = self._download_json(\n            r, video_id, note='Requesting media key',\n            errnote='Could not download media key')\n        if 'mediaKey' not in mkd:\n            raise ExtractorError('Did not get a media key')\n\n        redirect_url = compat_b64decode(video_url_base64).decode('utf-8')\n        redirect_req = HEADRequest(redirect_url)\n        req = self._request_webpage(\n            redirect_req, video_id,\n            note='Resolving final URL', errnote='Could not resolve final URL')\n        video_url = req.geturl()\n        if video_url.endswith('.html'):\n            raise ExtractorError('Redirect failed')\n\n        video_title = self._og_search_title(webpage).strip()\n\n        return {\n            'id': video_id,\n            'url': video_url,\n            'title': video_title,\n            'thumbnail': self._og_search_thumbnail(webpage),\n        }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/hotnewhiphop.py#L30-L66","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the video page still exists and plays at hotnewhiphop.com","Update youtube-dl/yt-dlp — the HNHH extractor has needed multiple rewrites","Try again later in case of rate limiting","Extract the final mp4 URL from browser devtools and download it directly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import requests\nr = requests.post('http://www.hotnewhiphop.com/ajax/media/getActions/',\n                  data={'mediaType': 's', 'mediaId': mid},\n                  headers={'Content-Type': 'application/x-www-form-urlencoded'})\nif 'mediaKey' not in r.json():\n    print('HNHH will fail: no mediaKey in getActions response')","typeGuard":"def hnhh_media_ready(mkd):\n    return isinstance(mkd, dict) and 'mediaKey' in mkd","tryCatchPattern":"try:\n    ydl.extract_info(url)\nexcept DownloadError as e:\n    if 'media key' in str(e):\n        retry_once_then_report(url)  # transient rate limit vs site change\n    else:\n        raise","preventionTips":["Update the tool before debugging — HNHH's AJAX API changes frequently","Space out requests; the endpoint rate-limits","Verify the video still exists in a browser first"],"tags":["hotnewhiphop","api-error","extractor","dead-link"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}