curl 'https://...googlevideo.com...' --output video.mp4
for me the download is throttled to "768k", i assume thats in bits per second and not bytes which is very low: the random video i tried would take 8 minutes.on the other hand,
yt-dlp videoIdHere
does its processing then downloads the whole thing in about 5 seconds.Does that curl command run much faster for you? Or do you do something else?
Use this post-data and should get higher speeed, e.g., 1.5 MiB/s. Test it and see if yt-dlp is faster. It shouldn't be.
{"context": {"client": {"clientName": "ANDROID", "clientVersion": "17.31.35", "androidSdkVersion": 30 }}, "videoId": "$x", "params": "CgIQBg==", "playbackContext": {"contentPlaybackContext": {"html5Preference": "HTML5_PREF_WANTS"}}, "contentCheckOk": true, "racyCheckOk": true}
I do not use curl, except in HN examples. I generally do not download from YouTube. I use the URLs in the JSON to watch the video.However, acquiring this key requires decompiling the mobile application, monitoring requests through a proxy, or relying on values discovered by others. It's not necessarily straightforward.
I do agree that the code is simpler this way.
I also find it interesting that, by default, yt-dlp calls the YouTube API three times, initially as an Android client, then as an iOS client, and finally as a Web client. Depending on the video and certain other parameters, YouTube provides different formats to different clients.
This is again not true. The key is in the HTML of every /watch?v= YouTube page. It's a public key; it's not hidden in any way.
Further, it's possible, up until today at least, to use the "WEB" key with clientName "ANDROID" of "IOS" and receive unthrottled URLs. The key in the shell script is in fact the WEB key. The key for IOS is different.
curl -40s https://www.youtube.com/watch?v=aqz-KE-bpKQ \
|grep -o \"INNERTUBE_API_KEY...[^\"]*\"
The post-data that OP is sending is different. That's why he's getting throttled URLs.
Moreover, to get throttled videoplayback URLs with the "WEB" key and client info like the OP is using, one does not need to make POST requests to /youtubei/v1/player. There are throttled videoplayback URLs in the HTML of the /watch?v= page. For example,
It's ironic how OP is claiming this is complicated. That's his own doing.