yt-dlp: [twitter] Video download Stopped Working. Failed to parse JSON
đ¨click HERE for a summary and WORKAROUNDSđ¨
Checklist
- Iâm reporting that yt-dlp is broken on a supported site
- Iâve verified that I have updated yt-dlp to nightly or master (update instructions)
- 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 known issues, the FAQ, and the bugtracker for similar issues including closed ones. DO NOT post duplicates
- Iâve read about sharing account credentials and Iâm willing to share it if required
Region
United States
Provide a description that is worded well enough to be understood
All twitter/x video parsing stopped working today. With the same error below
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': TruetoYoutubeDLparams instead - Copy the WHOLE output (starting with
[debug] Command-line config) and insert it below
Complete Verbose Output
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2025.03.07.232704 from yt-dlp/yt-dlp-nightly-builds[05c8023a2](pip) API
[debug] params: {'outtmpl': '%(id)s.%(ext)s', 'verbose': 'True', 'quiet': 'True', 'cookies': 'cookies_file.txt', 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
[debug] Python 3.9.7 (CPython AMD64 64bit) - Windows-10-10.0.x-SP0(OpenSSL 1.1.1s 1 Nov 2022)
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02, mutagen-1.47.0, requests-2.32.3, sqlite3-3.40.0, urllib3-2.2.1, websockets-13.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Plugin directories: none
[debug] Loaded 1844 extractors
[twitter] Extracting URL: https: // x.com/Catsillyness/status/1898936012136391109
[twitter] 1898936012136391109: Downloading guest token
[twitter] 1898936012136391109: Downloading GraphQL JSON
ERROR: [twitter] 1898936012136391109: 1898936012136391109: 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 ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 747, in extract
ie_result = self._real_extract(url)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 1388, in _real_extract
status = self._extract_status(twid)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 1366, in _extract_status
status = self._graphql_to_legacy(self._call_graphql_api(self._GRAPHQL_ENDPOINT, twid), twid)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 332, in _call_graphql_api
return traverse_obj(self._call_api(endpoint, media_id, query=query, graphql=True), 'data')
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 313, in _call_api
result = self._download_json(
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1144, in download_content
res = getattr(self, download_handle.__name__)(url_or_request, video_id, **kwargs)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1109, in download_handle
return parse(self, content, video_id, transform_source=transform_source, fatal=fatal, errnote=errnote), urlh
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1097, in parse
return getattr(ie, parser)(content, *args, **kwargs)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1084, in _parse_json
self.__print_error('Failed to parse JSON' if errnote is None else errnote, fatal, video_id, ve)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1067, in __print_error
raise ExtractorError(f'{video_id}: {errnote}', cause=err)
File ".\env\lib\site-packages\yt_dlp\utils\_utils.py", line 567, in decode
return super().decode(s)
File .\miniconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File .\miniconda3\lib\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 ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1081, in _parse_json
return json.loads(
File .\miniconda3\lib\json\__init__.py", line 359, in loads
return cls(**kw).decode(s)
File ".\env\lib\site-packages\yt_dlp\utils\_utils.py", line 575, 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 '': line 1 column 1 (char 0)
- ---------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 57507)
Traceback (most recent call last):
File ".\env\lib\site-packages\yt_dlp\utils\_utils.py", line 567, in decode
return super().decode(s)
File .\miniconda3\lib\json\decoder.py", line 337, in decode
obj, end= self.raw_decode(s, idx=_w(s, 0).end())
File .\miniconda3\lib\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 ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1081, in _parse_json
return json.loads(
File .\miniconda3\lib\json\__init__.py", line 359, in loads
return cls(**kw).decode(s)
File ".\env\lib\site-packages\yt_dlp\utils\_utils.py", line 575, 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 '': line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1651, in wrapper
return func(self, *args, **kwargs)
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1786, in __extract_info
ie_result= ie.extract(url)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 747, in extract
ie_result= self._real_extract(url)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 1388, in _real_extract
status= self._extract_status(twid)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 1366, in _extract_status
status= self._graphql_to_legacy(self._call_graphql_api(self._GRAPHQL_ENDPOINT, twid), twid)
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 332, in _call_graphql_api
return traverse_obj(self._call_api(endpoint, media_id, query=query, graphql=True), 'data')
File ".\env\lib\site-packages\yt_dlp\extractor\twitter.py", line 313, in _call_api
result= self._download_json(
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1144, in download_content
res= getattr(self, download_handle.__name__)(url_or_request, video_id, **kwargs)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1109, in download_handle
return parse(self, content, video_id, transform_source=transform_source, fatal=fatal, errnote=errnote), urlh
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1097, in parse
return getattr(ie, parser)(content, *args, **kwargs)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1084, in _parse_json
self.__print_error(
'Failed to parse JSON' if errnote is None else errnote, fatal, video_id, ve)
File ".\env\lib\site-packages\yt_dlp\extractor\common.py", line 1067, in __print_error
raise ExtractorError(f'{video_id}: {errnote}', cause=err)
yt_dlp.utils.ExtractorError: [twitter] 1898936012136391109: 1898936012136391109: 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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File .\miniconda3\lib\socketserver.py", line 316, in _handle_request_noblock
self.process_request(request, client_address)
File .\miniconda3\lib\socketserver.py", line 347, in process_request
self.finish_request(request, client_address)
File .\miniconda3\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File .\miniconda3\lib\socketserver.py", line 747, in __init__
self.handle()
File .\miniconda3\lib\http\server.py", line 427, in handle
self.handle_one_request()
File .\miniconda3\lib\http\server.py", line 415, in handle_one_request
method()
File ".\src\main.py", line 83, in parse_link
result= ydl.extract_info(
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1640, in extract_info
return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1669, in wrapper
self.report_error(str(e), e.format_traceback())
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1109, in report_error
self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
File ".\env\lib\site-packages\yt_dlp\YoutubeDL.py", line 1048, in trouble
raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: [twitter] 1898936012136391109: 1898936012136391109: 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
- ---------------------------------------
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 11
- Comments: 28 (8 by maintainers)
Since the GraphQL endpoint still works in my own Twitter scraping script, I tested
yt-dlpwith--add-headers "User-Agent: python-requests/2.32.3"(together with cookies) and it works here. Not sure how reliable this workaround would be.Cloudflare is blocking requests to the graphql endpoints. Impersonation doesnât help.
Workarounds:
--extractor-arg "twitter:api=legacy"to your command--extractor-arg "twitter:api=syndication"EDIT: If youâre using the python API, the equivalent parameter would be:
This is basically the same issue as #11937, but Iâll keep them open separately for now in case this one resolves itself and the other does not
Iâm on
nightly@2025.03.07.232704.extractor_argsandsyndicationapi did the trick. Thank you.It is working âUser-Agentâ: âpython-requests/2.32.3â by using this, thanks @hsn10
Potentially related to a recent twitter attack https://x.com/elonmusk/status/1899149509407473825 but would be nice to see a better message or an error code
Checkout here, it is working for me https://www.utilshub.com/x-video-downloader
âextractor-arg âtwitter:api=legacyâ didnât fixed the problem for me but adding --add-headers âUser-Agent: python-requests/2.32.3â works. Adding that Python UA is all it needs to work.
still having issue with
yt-dlp==2025.2.19andyt-dlp==2025.3.7.232704.dev0, still need to parse--extractor-arg "twitter:api=legacy"