sampa
sampa

Reputation: 639

Youtube get video file link

Im trying to extract the location for a saved youtube video file (like youtube downloader do).

When I use chromes developer tools I can easily see in the network section a GET request to the file. For example:

Request URL:ttps://r7---sn-35cxacf-43ce.googlevideo.com/videoplayback?sver=3&expire=1454883491&upn=tsTA82e-o9E&itag=251&id=o-APaDOeTiHGebIWBx11PdJn2W306GFYIoYkYRzOOCnq8o&mn=sn-35cxacf-43ce&mm=31&keepalive=yes&pl=32&ip=2a02%3A8071%3A2782%3A8c00%3Ad8e%3Aeb17%3Ab477%3Ad45b&ms=au&mv=m&mt=1454861758&ipbits=0&initcwndbps=1905000&clen=5116592&sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&key=yt6&gir=yes&fexp=3300130%2C3300161%2C3310848%2C3312381%2C3312708%2C9406984%2C9416126%2C9420452%2C9422596%2C9423661%2C9423662&mime=audio%2Fwebm&requiressl=yes&lmt=1449558944068050&dur=308.401&source=youtube&cpn=TrlaqPAJmEUJLKte&alr=yes&ratebypass=yes&signature=704658DBE8F05AC56D741F2061B2F16B0B5F37DD.6929579BD72F61B1401C96078192EC20BA8CE6EC&c=WEB&cver=html5&range=781669-1125882&rn=9&rbuf=43086
Request Method:GET
Status Code:200 OK
Remote Address:[*****address*****]:443

If I delete a few of the last params (starting at c=WEB) I got the location (see here)*. But how can I get this "request URL" by code? Do I need to analyze the network traffic? Or is there an other way?

*Its getting only the sound of the video file - but thats ok. The sound starts after 4 seconds.

A second way I tried: Getting the html-cocde of the normal youtubevideo (on youtube.com) and extracting and decoding the .googlevideo urls. But this way is not very safe, because I have to set up the url with some parameters and values which can be required or not for every video. So this way works only for every second video...

Does somebody know an other way to get the filelocation?

Upvotes: 3

Views: 10592

Answers (1)

user5859111
user5859111

Reputation:

The URLs are available through the ytplayer.config.args object. Keep in mind if they have "secured" the video you will have to jump through some serious hoops to get a usable URL, and maybe not even then.

How do all of these “Save video from YouTube” services work?

Upvotes: 3

Related Questions