yt-dlp: [foxnews] None: Failed to parse JSON

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

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

Checklist

  • I’m reporting a broken site
  • I’ve verified that I’m running yt-dlp version 2023.01.06 (update instructions) or later (specify commit)
  • I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue
  • I’ve read about sharing account credentials and I’m willing to share it if required

Region

anywhere

Provide a description that is worded well enough to be understood

Test link: https://www.foxnews.com/video/6318848717112

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

./yt-dlp -Uv -F "https://www.foxnews.com/video/6318848717112"
[debug] Command-line config: ['-Uv', '-F', 'https://www.foxnews.com/video/6318848717112']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2023.01.06 [6becd2508] (zip)
[debug] Python 3.10.9 (CPython arm64 64bit) - macOS-12.6.2-arm64-arm-64bit (OpenSSL 1.1.1s  1 Nov 2022)
[debug] exe versions: phantomjs 2.1.1
[debug] Optional libraries: sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1761 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2023.01.06, Current version: 2023.01.06
yt-dlp is up to date (2023.01.06)
[FoxNewsVideo] Extracting URL: https://www.foxnews.com/video/6318848717112
[foxnews] Extracting URL: https://video.foxnews.com/v/6318848717112
[foxnews] Downloading Akamai AMP feed
ERROR: [foxnews] 6318848717112: None: Failed to parse JSON (caused by JSONDecodeError("Expecting value in 'OK': 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/yt_dlp/extractor/common.py", line 682, in extract
    ie_result = self._real_extract(url)
  File "./yt-dlp/yt_dlp/extractor/foxnews.py", line 72, in _real_extract
    info = self._extract_feed_info(
  File "./yt-dlp/yt_dlp/extractor/amp.py", line 16, in _extract_feed_info
    feed = self._download_json(
  File "./yt-dlp/yt_dlp/extractor/common.py", line 1036, in download_content
    res = getattr(self, download_handle.__name__)(url_or_request, video_id, **kwargs)
  File "./yt-dlp/yt_dlp/extractor/common.py", line 1006, in download_handle
    return parse(self, content, video_id, transform_source=transform_source, fatal=fatal, errnote=errnote), urlh
  File "./yt-dlp/yt_dlp/extractor/common.py", line 996, in parse
    return getattr(ie, parser)(content, *args, **kwargs)
  File "./yt-dlp/yt_dlp/extractor/common.py", line 983, in _parse_json
    self.__print_error('Failed to parse JSON' if errnote is None else errnote, fatal, video_id, ve)
  File "./yt-dlp/yt_dlp/extractor/common.py", line 966, in __print_error
    raise ExtractorError(f'{video_id}: {errnote}', cause=err)

  File "./yt-dlp/yt_dlp/utils.py", line 606, in decode
    return super().decode(s)
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
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/yt_dlp/extractor/common.py", line 980, in _parse_json
    return json.loads(
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "./yt-dlp/yt_dlp/utils.py", line 609, in decode
    raise type(e)(f'{e.msg} in {s[e.pos-10:e.pos+10]!r}', s, e.pos)
json.decoder.JSONDecodeError: Expecting value in 'OK': line 1 column 1 (char 0)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 33 (5 by maintainers)

Commits related to this issue

Most upvoted comments

diff --git a/yt_dlp/extractor/amp.py b/yt_dlp/extractor/amp.py
index b0cbd775c..c6b1dc0c6 100644
--- a/yt_dlp/extractor/amp.py
+++ b/yt_dlp/extractor/amp.py
@@ -5,6 +5,7 @@
     int_or_none,
     mimetype2ext,
     parse_iso8601,
+    strip_jsonp,
     unified_timestamp,
     url_or_none,
 )
@@ -15,7 +16,7 @@ class AMPIE(InfoExtractor):  # XXX: Conventionally, base classes should end with
     def _extract_feed_info(self, url):
         feed = self._download_json(
             url, None, 'Downloading Akamai AMP feed',
-            'Unable to download Akamai AMP feed')
+            'Unable to download Akamai AMP feed', transform_source=strip_jsonp)
         item = feed.get('channel', {}).get('item')
         if not item:
             raise ExtractorError('%s said: %s' % (self.IE_NAME, feed['error']))
diff --git a/yt_dlp/extractor/foxnews.py b/yt_dlp/extractor/foxnews.py
index 52172aace..2172e0fbd 100644
--- a/yt_dlp/extractor/foxnews.py
+++ b/yt_dlp/extractor/foxnews.py
@@ -7,7 +7,7 @@
 class FoxNewsIE(AMPIE):
     IE_NAME = 'foxnews'
     IE_DESC = 'Fox News and Fox Business Video'
-    _VALID_URL = r'https?://(?P<host>video\.(?:insider\.)?fox(?:news|business)\.com)/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
+    _VALID_URL = r'https?://video\.(?:insider\.)?fox(?:news|business)\.com/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)'
     _TESTS = [
         {
             'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips',
@@ -67,10 +67,10 @@ def _extract_embed_urls(cls, url, webpage):
             yield f'https://video.foxnews.com/v/video-embed.html?video_id={mobj.group("video_id")}'
 
     def _real_extract(self, url):
-        host, video_id = self._match_valid_url(url).groups()
+        video_id = self._match_id(url)
 
         info = self._extract_feed_info(
-            'http://%s/v/feed/video/%s.js?template=fox' % (host, video_id))
+            f'https://api.foxnews.com/v3/video-player/{video_id}?callback=uid_{video_id}')
         info['id'] = video_id
         return info
 

I confirm the existence of the error. The problem does not depend on the country from which I am trying to access the FOX site.

yt-dlp is up to date (2023.01.06)

Will this possible be resolved? People outside the US cannot generate links with the generic information extractor.

Workaround: yt-dlp --force-generic https://www.foxnews.com/video/6319105077112