yt-dlp: [gem.cbc.ca] Failed to parse JSON: JSONDecodeError: Expecting value in '': line 1 column 1 (char 0)

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

Canada

Provide a description that is worded well enough to be understood

It normally works, but has stopped working. This includes videos downloaded as recently as a few days ago (but they now no longer work).

It’s failing to parse the returned JSON:

json.decoder.JSONDecodeError: Expecting value in ‘’: line 1 column 1 (char 0)

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', '--username', 'PRIVATE', '--password', 'PRIVATE', 'https://gem.cbc.ca/coronation-street/s01e11428']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.12.13 from yt-dlp/yt-dlp [542166962] (win_exe)
[debug] Python 3.10.11 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1t  7 Feb 2023)
[debug] exe versions: ffmpeg 7.0-essentials_build-www.gyan.dev (setts)
[debug] Optional libraries: Cryptodome-3.21.0, brotli-1.1.0, certifi-2024.08.30, curl_cffi-0.5.10, mutagen-1.47.0, requests-2.32.3, sqlite3-3.40.1, urllib3-2.2.3, websockets-14.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.12.13 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.12.13 from yt-dlp/yt-dlp)
[debug] Using fake IP 99.246.11.195 (CA) as X-Forwarded-For
[debug] Loading cbcgem.claims_token from cache
[gem.cbc.ca] Extracting URL: https://gem.cbc.ca/coronation-street/s01e11428
[gem.cbc.ca] coronation-street/s01e11428: Downloading JSON metadata
ERROR: [gem.cbc.ca] coronation-street/s01e11428: coronation-street/s01e11428: Failed to parse JSON (caused by JSONDecodeError("Expecting value in '': line 1 column 1 (char 0)")); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "yt_dlp\extractor\common.py", line 742, in extract
  File "yt_dlp\extractor\cbc.py", line 638, in _real_extract
  File "yt_dlp\extractor\common.py", line 1152, in download_content
  File "yt_dlp\extractor\common.py", line 1119, in download_handle
  File "yt_dlp\extractor\common.py", line 1107, in parse
  File "yt_dlp\extractor\common.py", line 1094, in _parse_json
  File "yt_dlp\extractor\common.py", line 1077, in __print_error

  File "yt_dlp\utils\_utils.py", line 565, in decode
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 1091, in _parse_json
  File "json\__init__.py", line 359, in loads
  File "yt_dlp\utils\_utils.py", line 573, in decode
json.decoder.JSONDecodeError: Expecting value in '': line 1 column 1 (char 0)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@OliveiraHermogenes actually nevermind I’ve got it fixed in the same PR.

The only thing that isn’t being fixed is login support, which is almost certainly broken. Someone with an account is welcome to open a new issue for that

@OliveiraHermogenes the season/playlist extractor was not touched by that patch. Could you open a new issue about that please? You can include the same log you just posted. I am going to be closing this issue very soon by merging #12404

Patch from above applied and tested. It’s working with a Canadian IP with and without --cookies-from-browser, at least with the following URL:

$ yt-dlp --verbose "https://gem.cbc.ca/daniel-tigers-neighbourhood/s01e11"
[debug] Command-line config: ['--verbose', 'https://gem.cbc.ca/daniel-tigers-neighbourhood/s01e11']
[debug] User config "/home/hermogenes/.config/yt-dlp/config": ['--embed-metadata', '--embed-thumbnail', '-o', '%(title)s.%(ext)s']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2025.01.26 from yt-dlp/yt-dlp [3b4531934] (debian*)
[debug] Python 3.13.2 (CPython x86_64 64bit) - Linux-6.12.13-amd64-x86_64-with-glibc2.40 (OpenSSL 3.4.1 11 Feb 2025, glibc 2.40)
[debug] exe versions: ffmpeg 7.1-3 (setts), ffprobe 7.1-3, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2025.01.31, mutagen-1.47.0, pyxattr-0.8.1, requests-2.32.3, sqlite3-3.46.1, urllib3-2.3.0, websockets-14.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1839 extractors
[debug] Using fake IP 99.247.186.128 (CA) as X-Forwarded-For
[gem.cbc.ca] Extracting URL: https://gem.cbc.ca/daniel-tigers-neighbourhood/s01e11
[gem.cbc.ca] daniel-tigers-neighbourhood/s01e11: Downloading JSON metadata
[gem.cbc.ca] daniel-tigers-neighbourhood/s01e11: Downloading JSON metadata
[gem.cbc.ca] daniel-tigers-neighbourhood/s01e11: Downloading m3u8 information
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec, channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] daniel-tigers-neighbourhood/s01e11: Downloading 1 format(s): hls-6708+hls-audio_2-English
[info] There are no video thumbnails to download
[debug] Invoking hlsnative downloader on "https://cbcrcott-aws-gem.akamaized.net/hdntl=exp=1740009274~acl=%2f*~data=hdntl~hmac=db508e28fa38a5bfb67ed006f170fb75678c174a0514fff24b4c7651e5ab4e78/out/v1/22c30f04f5144add9b855f2f0064f095/026bf27581e640c4b4fb78ae5aaa5021/4992c413374a4be4af23a7b5453f28df/39578817cdc1485bba869c97adac23ce/6baf985d549245c48f39e42930e10a5e/index-aes_3.m3u8?aka_me_session_id=AAAAAAAAAAA6b7ZnAAAAAJS4RwTcA43tIvq%2f2EGGQ5rdUdeFUMGGW9v0ivJ2J8XBpmMIVrfBZ2dtZdddrbWOSCzQvlvJ%2fRTR&aka_media_format_type=hls&pckgrp=bf5b9c2800b7e86d48330ceb5add54a4"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 528
[download] Destination: Daniel Tiger's Neighbourhood.fhls-6708.mp4

OS: Debian unstable Patch applied to version: 2025.01.26 (Debian package)

I thought that the 1st API had been updated already, but it was a WIP on the travel laptop. Here’s a full diff to master:

--- old/yt-dlp/yt_dlp/extractor/cbc.py
+++ new/yt-dlp/yt_dlp/extractor/cbc.py
@@ -21,6 +21,7 @@
     traverse_obj,
     try_get,
     update_url,
+    update_url_query,
     url_basename,
     url_or_none,
 )
@@ -636,8 +637,8 @@
     def _real_extract(self, url):
         video_id = self._match_id(url)
         video_info = self._download_json(
-            f'https://services.radio-canada.ca/ott/cbc-api/v2/assets/{video_id}',
-            video_id, expected_status=426)
+            f'https://services.radio-canada.ca/ott/catalog/v2/gem/show/{video_id}?device=web',
+            video_id)
 
         email, password = self._get_login_info()
         if email and password:
@@ -645,7 +646,15 @@
             headers = {'x-claims-token': claims_token}
         else:
             headers = {}
-        m3u8_info = self._download_json(video_info['playSession']['url'], video_id, headers=headers)
+
+        media_id = traverse_obj(video_info, (
+            'content', ..., 'lineups', ..., 'items',
+            lambda _, v: v['url'] == video_id, 'idMedia', any))
+        m3u8_info_url = update_url_query(
+            'https://services.radio-canada.ca/media/validation/v2/?appCode=gem&connectionType=hd&deviceType=ipad&multibitrate=true&output=json&tech=hls&manifestVersion=2&manifestType=desktop', {
+                'idMedia': media_id,
+        })
+        m3u8_info = self._download_json(m3u8_info_url, video_id, headers=headers)
 
         if m3u8_info.get('errorCode') == 1:
             self.raise_geo_restricted(countries=['CA'])

You can see these API URLs in the browser tools with the trailer page (gem.cbc.com and services.radio-canada.ca must be enabled for JS).

Instead of the catalog JSON, one could use the .props.pageProps.data member of the __NEXT_DATA__ in the webpage, which also contains .content with the complete series data by season and episode in the same format … until they switch to the new-style hydration data.

I’m willing to download from GEM CBC, with the same config (geo block, account)

As long as this issue is not marked as resolved, there is no point trying, right ?

EDIT: I tested with latest master update and it is indeed impossible to download from https://gem.cbc.ca/