{"record":{"id":"b11934a1deaeb962","repo":"ytdl-org/youtube-dl","slug":"error-b11934","errorCode":null,"errorMessage":"error","messagePattern":"error","errorType":"exception","errorClass":"ExtractorError","httpStatus":401,"severity":"error","filePath":"youtube_dl/extractor/radiocanada.py","lineNumber":85,"sourceCode":"        query.update({\n            'client_key': '773aea60-0e80-41bb-9c7f-e6d7c3ad17fb',\n            'output': 'json',\n        })\n        if video_id:\n            query.update({\n                'appCode': app_code,\n                'idMedia': video_id,\n            })\n        if self._access_token:\n            query['access_token'] = self._access_token\n        try:\n            return self._download_json(\n                'https://services.radio-canada.ca/media/' + path, video_id, query=query)\n        except ExtractorError as e:\n            if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 422):\n                data = self._parse_json(e.cause.read().decode(), None)\n                error = data.get('error_description') or data['errorMessage']['text']\n                raise ExtractorError(error, expected=True)\n            raise\n\n    def _extract_info(self, app_code, video_id):\n        metas = self._call_api('meta/v1/index.ashx', video_id, app_code)['Metas']\n\n        def get_meta(name):\n            for meta in metas:\n                if meta.get('name') == name:\n                    text = meta.get('text')\n                    if text:\n                        return text\n\n        # protectionType does not necessarily mean the video is DRM protected (see\n        # https://github.com/ytdl-org/youtube-dl/pull/18609).\n        if get_meta('protectionType'):\n            self.report_warning('This video is probably DRM protected.')\n\n        query = {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/radiocanada.py#L67-L103","documentation":"RadioCanadaBaseIE._call_api catches an ExtractorError whose cause is an HTTP 401 or 422 from services.radio-canada.ca, parses the error response JSON, and re-raises ExtractorError with the API's own message — taken from error_description or errorMessage.text — marked expected=True. The cataloged message 'error' is just the placeholder shape; the real text at runtime is whatever Radio-Canada returned (e.g. 'invalid media id').","triggerScenarios":"Any _call_api request (meta/v1/index.ashx, validation/v2/, etc.) where the API answers 401 (auth failure / bad token) or 422 (unprocessable — usually unknown idMedia or appCode); the body must be JSON containing error_description or errorMessage.text, otherwise _parse_json itself fails.","commonSituations":"Expired or absent access_token when one is set on the instance; wrong appCode/media id pairs (e.g. radio-canada vs touvi instances); content IDs from a different API tier; API contract changes after a youtube-dl release.","solutions":["Verify the video/appCode pair is correct for the site you are extracting (Radio-Canada vs Tou.tv use different app codes).","Update youtube-dl — token handling and endpoints for this service have changed over time.","If authentication-related (401), ensure any required token flow is not being skipped and retry with a fresh session.","Confirm the media id actually exists by opening the page in a browser."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    info = ydl.extract_info(url)\nexcept ExtractorError as e:\n    if 'RadioCanada' in str(e) or 'Radio-Canada' in str(e):\n        inspect_http_status(e)  # 401 vs 422 hints at token vs id","preventionTips":["Match the appCode to the actual site (Radio-Canada vs Tou.tv) when constructing calls.","Treat 401 as token/session trouble and 422 as bad ids.","Update the extractor when the API error schema changes."],"tags":["radiocanada","api-error","http-401","http-422"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}