yt-dlp: [TikTok] Failed to parse JSON/ No video formats found
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
- I’m asking a question and not reporting a bug or requesting a feature
- I’ve looked through the README
- I’ve verified that I have updated yt-dlp to nightly or master (update instructions)
- I’ve searched known issues and the bugtracker for similar questions including closed ones. DO NOT post duplicates
- I’ve read the guidelines for opening an issue
Please make sure the question is worded well enough to be understood
EDIT:
yt-dlp’s TikTok extractor is failing to parse JSON from the feed API endpoint even on nightly/master or with passing --extractor-args "tiktok:api_hostname=api22-normal-c-useast2a.tiktokv.com"
original log for reference
yt-dlp -f "bv*[vcodec^=avc]+ba[ext=m4a]/b[ext=mp4]/b" https://www.tiktok.com/@pouveronica/video/7322479967147740459
[TikTok] Extracting URL: https://www.tiktok.com/@pouveronica/video/7322479967147740459
[TikTok] 7322479967147740459: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 1 of 4)
[TikTok] 7322479967147740459: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 2 of 4)
[TikTok] 7322479967147740459: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 3 of 4)
[TikTok] 7322479967147740459: Downloading video feed
WARNING: [TikTok] 7322479967147740459: Failed to parse JSON (caused by JSONDecodeError("Expecting value in '': line 1 column 1 (char 0)")); trying with webpage
[TikTok] 7322479967147740459: Downloading webpage
[info] 7322479967147740459: Downloading 1 format(s): download
ERROR: unable to open for writing: [Errno 2] No such file or directory: 'Replying to @Vy Puthny some key differences in finance and accounting 😃 #hr #humanresources #hrinsight #hrrole #hrtips #hrtrend #hrknowledge #learning #careergrowth #accounting #finance #manpoweroutsourcing #eor @Nica - និកា [7322479967147740459].mp4.part'
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
toYoutubeDL
params instead - Copy the WHOLE output (starting with
[debug] Command-line config
) and insert it below
Complete Verbose Output
[debug] Command-line config: ['-v', '-U', '-o', '%(title).200B.%(ext)s', 'https://www.tiktok.com/@mix_editor_5/video/7342789941371571462']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version master@2024.03.20.232831 from yt-dlp/yt-dlp-master-builds [07f5b2f75] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1k 25 Mar 2021)
[debug] exe versions: ffmpeg 6.1.1-full_build-www.gyan.dev (setts), ffprobe 6.1.1-full_build-www.gyan.dev, phantomjs 2.5.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02, curl_cffi-0.5.10, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.2.1, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1806 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-master-builds/releases/latest
Latest version: master@2024.03.20.232831 from yt-dlp/yt-dlp-master-builds
yt-dlp is up to date (master@2024.03.20.232831 from yt-dlp/yt-dlp-master-builds)
[TikTok] Extracting URL: https://www.tiktok.com/@mix_editor_5/video/7342789941371571462
[TikTok] 7342789941371571462: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 1 of 4)
[TikTok] 7342789941371571462: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 2 of 4)
[TikTok] 7342789941371571462: Downloading video feed
WARNING: [TikTok] Expecting value in '': line 1 column 1 (char 0). Retrying... (attempt 3 of 4)
[TikTok] 7342789941371571462: Downloading video feed
WARNING: [TikTok] 7342789941371571462: Failed to parse JSON (caused by JSONDecodeError("Expecting value in '': line 1 column 1 (char 0)")); trying with webpage
[TikTok] 7342789941371571462: Downloading webpage
[debug] [TikTok] Found universal data for rehydration
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 7342789941371571462: Downloading 1 format(s): download
[debug] Invoking http downloader on "https://v16-webapp-prime.tiktok.com/video/tos/useast2a/tos-useast2a-ve-0068c004/okMCLjLWAqjFQ5CIXaAfaAiMNgbSzfFCh48fSV/?a=1988&ch=0&cr=3&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C&cv=1&br=1800&bt=900&bti=ODszNWYuMDE6&cs=0&ds=3&ft=4fUEKMFx8Zmo0H.5Y94jV..7rpWrKsd.&mime_type=video_mp4&qs=0&rc=NGQ5OTY1NTdnaDM0Ojs1ZUBpMzs4N3Q5cnlncTMzNzczM0AzLi9gMi4vNjUxX14uLV4yYSNqZWpoMmQ0NWdgLS1kMTZzcw%3D%3D&btag=e00088000&expire=1711056619&l=20240321153003FA72D5DD8E2EFA514E6F&ply_type=2&policy=2&signature=eb207c9a24f5509f1e4668cbac840d00&tk=tt_chain_token"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: #CapCut #🥺💔 #new #trending #plz #plz #😭😭 #viralvideo #plunfrezzmyaccount🙏🥺 #plzvirulvideo😥 #plzviral🥺🥺🙏🙏foryoupage ⧸⧸ 𝑫𝒆𝒂𝒓 𝑻𝒊𝒌𝒕𝒐𝒌 𝑻.mp4
[download] 100% of 1.62MiB in 00:00:00 at 14.79MiB/s
About this issue
- Original URL
- State: open
- Created 3 months ago
- Reactions: 7
- Comments: 38 (6 by maintainers)
while I am against hardcoding someone else’s
iid
into the extractor, perhaps a “bring your owniid
” approach would be acceptable until a better/proper solution is found.here’s a patch with a minimal diff that would allow you to pass
--extractor-args "tiktok:iid=VALUE"
, replacingVALUE
with an actual workingiid
valueI’m not very related to tiktok extractor. But I think that with this piece of code can solve the problem. The json response is identical to what the old api used to respond:
Yes it does
The endpoint hasn’t been down. It has become more restricted. One solution to these increased restrictions is to pass an
iid
&device_id
pair.Each installation of the TT mobile app is assigned a unique
iid
value, presumably for security and tracking purposes. If we were to add this 1iid
value to yt-dlp’s TT extractor, then due to the volume of yt-dlp users, there is a high probability that thisiid
would be blocked by TT shortly after the next stable release (if not sooner). IMO this is not a viable solution. It would be fairly easy to create a plugin that utilizes this solution, thoughformat 0 but quality is not good
A verbose log is just about always required when reporting a bug, as it shows things such as the version of yt-dlp, device you are running on, proxies used, dependencies installed, extra setting from a config file…
^ nah this is how we were always doing it
^ this is what is new, and what I’ve seen a couple other projects on github start doing today.
TikTok seems to be enforcing/checking the
iid
anddevice_id
params now for the feed endpoint. The problem here, is thatiid
is the installation id of the mobile app anddevice_id
is the accompanying id for the mobile device on which it is installed. These params cannot be faked with random values. So since thisiid
anddevice_id
belong to a real TikTok installation on someone’s device, it’s likely only a matter of time before it is banned for spam/scraping@bashonly Seems like a decent workaround. Is there an easy way to get our own iid from the iOS tiktok app?
it does not work, bro.
Anyone have any ideas on how to fix this?
try it, work well.
https://www.tiktokarchive.com/
That’s because some specific cookies have to be passed with the request, which your browser obviously doesn’t do. So it’s not an actual problem in this caseJust checked the code, it isn’t. Sorry for misinformationyt-dlp should still be able to download the webpage version of the video in most cases. Try adding
-f 0
to your command to select the format without a watermark. The quality will not be quite as good as the mobile API feed formats, though.If you get an error like this, it just means the output filename is too long. Add
-o "%(title).100B [%(id)s].%(ext)s"
to your commandYou get a verbose log by adding
--verbose
(or-v
for short) to your command: