{"record":{"id":"f57de3640d64b5d0","repo":"ytdl-org/youtube-dl","slug":"response-body-message","errorCode":null,"errorMessage":"response['body']['message']","messagePattern":"response\\['body'\\]\\['message'\\]","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/hotstar.py","lineNumber":49,"sourceCode":"        exp = st + 6000\n        auth = 'st=%d~exp=%d~acl=/*' % (st, exp)\n        auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()\n        h = {'hotstarauth': auth}\n        h.update(headers)\n        return self._download_json(\n            'https://api.hotstar.com/' + path,\n            video_id, headers=h, query=query, data=data)\n\n    def _call_api(self, path, video_id, query_name='contentId'):\n        response = self._call_api_impl(path, video_id, {\n            'x-country-code': 'IN',\n            'x-platform-code': 'JIO',\n        }, {\n            query_name: video_id,\n            'tas': 10000,\n        })\n        if response['statusCode'] != 'OK':\n            raise ExtractorError(\n                response['body']['message'], expected=True)\n        return response['body']['results']\n\n    def _call_api_v2(self, path, video_id, headers, query=None, data=None):\n        h = {'X-Request-Id': compat_str(uuid.uuid4())}\n        h.update(headers)\n        try:\n            return self._call_api_impl(\n                path, video_id, h, query, data)\n        except ExtractorError as e:\n            if isinstance(e.cause, compat_HTTPError):\n                if e.cause.code == 402:\n                    self.raise_login_required()\n                message = self._parse_json(e.cause.read().decode(), video_id)['message']\n                if message in ('Content not available in region', 'Country is not supported'):\n                    raise self.raise_geo_restricted(message)\n                raise ExtractorError(message)\n            raise e","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/hotstar.py#L31-L67","documentation":"Raised by the Hotstar extractor's _call_api when the API response's statusCode is not 'OK'; the message comes from response['body']['message']. Marked expected=True. Note: if body or message is missing on a non-OK response this line KeyErrors, but the normal path surfaces Hotstar's own message (geo, entitlement, not-found).","triggerScenarios":"Calling api.hotstar.com with x-country-code: IN and x-platform-code: JIO for content that is not available in India, is premium-only, or has been removed — statusCode comes back non-OK with an error body.","commonSituations":"Premium Hotstar content without subscription login, region-locked content (headers force IN region), removed matches/episodes, or old builds predating Hotstar's API changes (now JioHotstar).","solutions":["Read the body message with -v: it distinguishes geo vs entitlement vs not-found","For premium content, pass credentials/cookies of an entitled account","Update to yt-dlp — Hotstar's API and headers changed repeatedly","Verify the content still plays on hotstar.com in a browser"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import requests\nresp = requests.get(f'https://api.hotstar.com/{path}', params={'contentId': vid, 'tas': 10000}, headers={'x-country-code': 'IN', 'x-platform-code': 'JIO'}).json()\nif resp.get('statusCode') != 'OK':\n    print('Hotstar refusal:', resp.get('body', {}).get('message'))","typeGuard":"def hotstar_ok(response):\n    return (\n        isinstance(response, dict)\n        and response.get('statusCode') == 'OK'\n        and isinstance(response.get('body'), dict)\n        and 'results' in response['body']\n    )","tryCatchPattern":"try:\n    ydl.extract_info(url)\nexcept DownloadError as e:\n    if 'Hotstar' in str(e) or 'hotstar' in str(e):\n        classify_and_log(url, str(e))  # geo vs entitlement vs removed\n    else:\n        raise","preventionTips":["Pass entitled account cookies for premium content","Remember the extractor pins x-country-code: IN — region availability is judged for India","Update to yt-dlp when Hotstar/JioHotstar API changes land"],"tags":["hotstar","api-error","entitlement","geo-restriction"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}