1

I wonder how to get the direct url of youtube video. For example, when i analyzed the video code of https://www.youtube.com/watch?v=OrTyD7rjBpw

i found some URLs inside the js code of the player, like https://r6---sn-w511uxa-cjoe.googlevideo.com/videoplayback?mt=1440164084&mv=m&ms=au&mm=31&mn=sn-w511uxa-cjoe&upn=ELDhWOVFRzM&id=o-AM6zxCNJwi5l5gjbq_262NpEnieXQ2iQTkGLLDieVKs4&ip=188.77.186.165&sparams=dur%2Cgcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpcm2cms%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&fexp=3300113%2C3300134%2C3300137%2C3300164%2C3310699%2C3312381%2C3312531%2C9407535%2C9408710%2C9409069%2C9412877%2C9413010%2C9414935%2C9415365%2C9415417%2C9415485%2C9416023%2C9416105%2C9416126%2C9416522%2C9417353%2C9417707%2C9418060%2C9418153%2C9418203%2C9418449%2C9419675&dur=0.000&initcwndbps=1298750&pl=20&ratebypass=yes&source=youtube&gcr=es&pcm2cms=yes&requiressl=yes&expire=1440185744&mime=video%2Fwebm&key=yt5&ipbits=0&lmt=1365511426344921&sver=3&itag=43

But it doesn't redirect to the youtube video, so i'm thinking that code is more obfuscated

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Fosfor
  • 331
  • 2
  • 3
  • 15

1 Answers1

3

There's a library for that, and a linux tool, called youtube-dl and libquvi, respectively, which support URL extraction from player pages. You can call youtube-dl -g https://www.youtube.com/watch?v=OrTyD7rjBpw to get a URL pointing to the video.

Note that many CDNs won't give you a redistributable URL for a video -- instead, it's a URL that will only work for whoever requested the video.

Also note: there's not "one" video stream at a youtube page, but several ones, for different qualities and devices.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94