ytdl-org/youtube-dl · error · ExtractorError

error

Error message

error

What it means

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').

Source

Thrown at youtube_dl/extractor/radiocanada.py:85

        query.update({
            'client_key': '773aea60-0e80-41bb-9c7f-e6d7c3ad17fb',
            'output': 'json',
        })
        if video_id:
            query.update({
                'appCode': app_code,
                'idMedia': video_id,
            })
        if self._access_token:
            query['access_token'] = self._access_token
        try:
            return self._download_json(
                'https://services.radio-canada.ca/media/' + path, video_id, query=query)
        except ExtractorError as e:
            if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 422):
                data = self._parse_json(e.cause.read().decode(), None)
                error = data.get('error_description') or data['errorMessage']['text']
                raise ExtractorError(error, expected=True)
            raise

    def _extract_info(self, app_code, video_id):
        metas = self._call_api('meta/v1/index.ashx', video_id, app_code)['Metas']

        def get_meta(name):
            for meta in metas:
                if meta.get('name') == name:
                    text = meta.get('text')
                    if text:
                        return text

        # protectionType does not necessarily mean the video is DRM protected (see
        # https://github.com/ytdl-org/youtube-dl/pull/18609).
        if get_meta('protectionType'):
            self.report_warning('This video is probably DRM protected.')

        query = {

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Verify the video/appCode pair is correct for the site you are extracting (Radio-Canada vs Tou.tv use different app codes).
  2. Update youtube-dl — token handling and endpoints for this service have changed over time.
  3. If authentication-related (401), ensure any required token flow is not being skipped and retry with a fresh session.
  4. Confirm the media id actually exists by opening the page in a browser.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    info = ydl.extract_info(url)
except ExtractorError as e:
    if 'RadioCanada' in str(e) or 'Radio-Canada' in str(e):
        inspect_http_status(e)  # 401 vs 422 hints at token vs id

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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