Reverse-Engineering YouTube: Revisited #21
Replies: 21 comments 43 replies
-
Was trying to use thsi to make my own downloader in JS, but no matter what video ID i use i always get: {
responseContext: {
visitorData: 'CgtwTHNOWHIzclBzbyjAy8OmBg%3D%3D',
serviceTrackingParams: [ [Object], [Object], [Object], [Object], [Object] ]
},
playabilityStatus: {
status: 'ERROR',
reason: 'This video is unavailable',
errorScreen: { playerErrorMessageRenderer: [Object] },
skip: { playabilityErrorSkipConfig: [Object] },
contextParams: 'Q0FFU0FnZ0I='
},
trackingParams: 'CAAQu2kiEwiLsfKtyMqAAxUBw5wKHdORCVY=',
playerSettingsMenuData: {
loggingDirectives: {
trackingParams: 'CAEQtc4GIhMIi7HyrcjKgAMVAcOcCh3TkQlW',
visibility: [Object],
enableDisplayloggerExperiment: true
}
},
adBreakHeartbeatParams: 'Q0FBJTNE',
frameworkUpdates: { entityBatchUpdate: { mutations: [Array], timestamp: [Object] } }
} My code is: const response = await fetch('https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w', {
method: 'POST',
body: JSON.stringify({
"videoId": 'kt_ELiL-GIQ',
"context": {
"client": {
"clientName": "ANDROID",
"clientVersion": "17.10.35",
"androidSdkVersion": 30
}
}
}),
})
const data = await response.json();
console.log(data); |
Beta Was this translation helpful? Give feedback.
-
TYSM!
…On Mon, Aug 7, 2023 at 8:44 AM Oleksii Holub ***@***.***> wrote:
A few things changed regarding the Android client in the past few months.
Try adding the following header (with the version numbers matching the
client in the request body):
request.Headers.Add(
"User-Agent",
"com.google.android.youtube/17.36.4 (Linux; U; Android 12; GB) gzip");
For reference, take a look at the working example here:
https://github.com/Tyrrrz/YoutubeExplode/blob/fed964ff706970dc654910587298c790a56e90c1/YoutubeExplode/Videos/VideoController.cs#L46-L97
—
Reply to this email directly, view it on GitHub
<#21 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYP25PFMSANS3SYOEBD2DZ3XUDPJXANCNFSM6AAAAAAURD7U7A>
.
You are receiving this because you commented.Message ID: <Tyrrrz/Tyrrrz.
***@***.***>
--
[image: avatar]
Jeremiah Ihab Samuel
CEO & Founder / TechLion Dev
Website: www.techlion.dev
Email: ***@***.***
Phone: +1 (732) 788-6322 <+1+(732)+788-6322>
[image: social-icon-youtube] ***@***.***>
[image: social-icon-github] <https://github.com/JeremiahISDev>
|
Beta Was this translation helpful? Give feedback.
-
how can i download video playlist |
Beta Was this translation helpful? Give feedback.
-
Thnks you. when i try to make request to the endpoint you provided i get a cors policy error. please help me what should is do. did i miss some thing ? |
Beta Was this translation helpful? Give feedback.
-
Hello, do you or anyone know if it is possible to set a start time for the video/audio file directly in the url like "&start=" query does in normal YouTube link? Thus starting playback from a predetermined time of the video (without ffmpeg). |
Beta Was this translation helpful? Give feedback.
-
Does the https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w url still working? Because is now working for me anymore. I received the next error:
and this is my code in php:
|
Beta Was this translation helpful? Give feedback.
-
hello what parameters to filter search results to "playlist" |
Beta Was this translation helpful? Give feedback.
-
i get this
this is my code in python
|
Beta Was this translation helpful? Give feedback.
-
Hello Oleksii,
Thank you again for your answer. |
Beta Was this translation helpful? Give feedback.
-
Hi Oleksii, Dose the API key is necessary for a player endpoint request? I noticed that I'm able to retrieve a video playback URL from the Here's the Python code snippet I used to make the request: import requests
import json
url = "https://music.youtube.com/youtubei/v1/player"
payload = json.dumps({
"context": {
"client": {
"hl": "en",
"gl": "US",
"clientName": "ANDROID_MUSIC",
"clientVersion": "5.26.1"
}
},
"videoId": "VcNFJE6k2_Q"
})
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 OPR/109.0.0.0 (Edition GX-CN)',
'Content-Type': 'application/json',
'Accept': '*/*',
'Host': 'music.youtube.com',
'Connection': 'keep-alive'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text) The response still includes the playback URL: "adaptiveFormats": [
{
"itag": 137,
"url": "https://rr4---sn-5uaezny6.googlevideo.com/videoplayback?expire=1719151210&ei=CtZ3Zv25MvDtsfIPncqEwAQ&ip=2a09%3Abac5%3A80cd%3A28%3A%3A4%3A338&id=o-AGwr3xtiSYjnloLxOi0xDulcYsYzH5f2QlCmNXOTPKon&itag=137&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=5F&mm=31%2C26&mn=sn-5uaezny6%2Csn-p5qs7nsk&ms=au%2Conr&mv=m&mvi=4&pl=42&gcr=us&initcwndbps=1696250&vprv=1&svpuc=1&mime=video%2Fmp4&rqh=1&gir=yes&clen=5911436&dur=220.160&lmt=1629540612355158&mt=1719129402&fvip=5&keepalive=yes&c=ANDROID_MUSIC&txp=5532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cgcr%2Cvprv%2Csvpuc%2Cmime%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRAIgWQw9FJvSvpEOZvu6xbJUtzxlJ35EyNCpUI72g_K4ieACIFnGZnlxgTcRDwCHXzccxLmgn1K66NY3wxLlHB49vvIQ&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHlkHjAwRQIgXkHdRcojOtcf2iVEb1pSZ8REACwhbZ6aDQ9qYMUy9MYCIQCW-1wuIGg0iwXBN5gKe3e3ZhznpbvfjAPNaPushfhlmw%3D%3D",
"mimeType": "video/mp4; codecs=\"avc1.640020\"",
// other details
} Really appreciate all your work on this! |
Beta Was this translation helpful? Give feedback.
-
I got this responce from youtube. { My code : a={ "playbackContext": {"contentPlaybackContext": {"signatureTimestamp" : "19906"}}} response = requests.post('https://www.youtube.com/youtubei/v1/player?key=YOUR_API_KEY',data=json.dumps(a),headers=headers) with open('data.json', 'w') as f: cipher code: let data = IPa( now the URL I got as a response is different than explained in the blog so can you please tell me how to retrieve the streams? |
Beta Was this translation helpful? Give feedback.
-
Does it stream from a single HTTP call or is it multiple calls? When I look in the dev console it seems to keep calling the same /videoplayback endpoint but with "rn" query param incrementing each time it calls, which seems to get a chunk of the data each time. |
Beta Was this translation helpful? Give feedback.
-
Good day First of all, I want to thank you for your work. def get_data(self) -> Dict[str, Union[str, int, Dict[str, Union[str, int]]]]:
|
Beta Was this translation helpful? Give feedback.
-
You mentioned that the metadata contains information about ad placements. Do you have any more details about that? Ad blocking seems not to be fully effective for me any more, and I'm trying to find out if anything can be done about it. |
Beta Was this translation helpful? Give feedback.
-
they are asking for sign in what params should i pass URl -> https://www.youtube.com/youtubei/v1/player?key=AIzaSyBUPetSUmoZL-OhlxA7wSac5XinrygCqMo Response -> |
Beta Was this translation helpful? Give feedback.
-
Thanks for your greatness article which is helps a lot of people who using their own solutions instead of libraries. Can I ask you what you mean under
Does it need to decrypt the signature, add it to the query and decrypt it again with |
Beta Was this translation helpful? Give feedback.
-
Hi, there is a deprecation notice for v1 and this article seems to depend on that version ( |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I'm having a 403 error even with |
Beta Was this translation helpful? Give feedback.
-
I created a typescript snippet that can be used to resolve Youtube video url's, and basic info. Its meant for use in Node.js, so it's not going to work in the browser due to CORS. For the people interested: https://gist.github.com/erdesigns-eu/1811c9a4038b28cd0d39b6207c329384 If you do use it, please add a comment at the gist :-) |
Beta Was this translation helpful? Give feedback.
-
First of all thank you for this solution, im building a unity C# application and i need a youtube downloader in it, Responce: The video is always not available in my case. Is there a stable way to get youtube download URLs ? |
Beta Was this translation helpful? Give feedback.
-
I am getting 403 error when I try to download video or audio. please help 🥺. |
Beta Was this translation helpful? Give feedback.
-
Reverse-Engineering YouTube: Revisited
Back in 2017 I wrote an article in which I attempted to explain how YouTube works under the hood, how it serves streams to the client, and also how you can exploit that knowledge to download videos from the site. The primary goal of that write-up was to…
http://tyrrrz.me/blog/reverse-engineering-youtube-revisited
Beta Was this translation helpful? Give feedback.
All reactions