FordLawnmower commented on a Page, Youtube Video Search/Downloader  -  May 01, 2011

I'm going to try to quickly explain how this works because I'm getting a lot of questions from people wanting to make a youtube downloader in another language.
First : They keep changing it , but the solution can always be found in the source ; in the flash player section.

  • Currently it starts like this:
<div id="watch-player" class="flash-player">
  • In this section you can find all the information you need to download a video between
fmt_url_map=
  • And
&amp;
  • I used this regex match to get the information between them.
/fmt_url_map=(.*?)&/
  • Once you have The url information you can use most any urldecode function to decode it so you can read it.
    It will start out something like this:
35%7Chttp%3A%2F%2Fv6.lscache4.c.youtube.com%2Fvideoplayback%3Fsparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26algorithm%3Dthrottle-factor%26itag%3D35%26ipbits%3D8%26burst%3D40%26sver%3D3%26signature%3DA9B7F2AC733E05D7369DF0C6B2C0A802B6D9C8ED.92042D6A86879855EB9FB1B107AC53C5C5626953%26expire%3D1304308800%26key%3Dyt1%26ip%3D174.0.0.0%26factor%3D1.25%26id%3D11afdc068b4f226d%2C34%7Chttp%3A%2F%2Fv23.lscache4.c.youtube.com%2Fvideoplayback%3Fsparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26algorithm%3Dthrottle-factor%26itag%3D34%26ipbits%3D8%26burst%3D40%26sver%3D3%26signature%3D4CE3A0C2E09B92A066F824B006801FF41E0FA636.1701E51A241559F14A57B37F1AC9A8E0B1C7D9DA%26expire%3D1304308800%26key%3Dyt1%26ip%3D174.0.0.0%26factor%3D1.25%26id%3D11afdc068b4f226d%2C18%7Chttp%3A%2F%2Fv9.lscache2.c.youtube.com%2Fvideoplayback%3Fsparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26algorithm%3Dthrottle-factor%26itag%3D18%26ipbits%3D8%26burst%3D40%26sver%3D3%26signature%3D84306C633F7DC4FD7D0751304B7EC81260254E3D.59959ED5D66A41F49C53AC860EF2C025121C64E9%26expire%3D1304308800%26key%3Dyt1%26ip%3D174.0.0.0%26factor%3D1.25%26id%3D11afdc068b4f226d%2C5%7Chttp%3A%2F%2Fv16.lscache1.c.youtube.com%2Fvideoplayback%3Fsparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26algorithm%3Dthrottle-factor%26itag%3D5%26ipbits%3D8%26burst%3D40%26sver%3D3%26signature%3D0F05799111FFBCC21278F2D345FD4F331DA61BB8.94D4070F6869448CAED16803C48CB2EDF5F44F3B%26expire%3D1304308800%26key%3Dyt1%26ip%3D174.0.0.0%26factor%3D1.25%26id%3D11afdc068b4f226d

Crazy ;/ I know.
After you run it through urldecode it will look something like this:

35|http://v6.lscache4.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&algorithm=throttle-factor&itag=35&ipbits=8&burst=40&sver=3&signature=A9B7F2AC733E05D7369DF0C6B2C0A802B6D9C8ED.92042D6A86879855EB9FB1B107AC53C5C5626953&expire=1304308800&key=yt1&ip=174.0.0.0&factor=1.25&id=11afdc068b4f226d,34|http://v23.lscache4.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&signature=4CE3A0C2E09B92A066F824B006801FF41E0FA636.1701E51A241559F14A57B37F1AC9A8E0B1C7D9DA&expire=1304308800&key=yt1&ip=174.0.0.0&factor=1.25&id=11afdc068b4f226d,18|http://v9.lscache2.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&algorithm=throttle-factor&itag=18&ipbits=8&burst=40&sver=3&signature=84306C633F7DC4FD7D0751304B7EC81260254E3D.59959ED5D66A41F49C53AC860EF2C025121C64E9&expire=1304308800&key=yt1&ip=174.0.0.0&factor=1.25&id=11afdc068b4f226d,5|http://v16.lscache1.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&algorithm=throttle-factor&itag=5&ipbits=8&burst=40&sver=3&signature=0F05799111FFBCC21278F2D345FD4F331DA61BB8.94D4070F6869448CAED16803C48CB2EDF5F44F3B&expire=1304308800&key=yt1&ip=174.0.0.0&factor=1.25&id=11afdc068b4f226d

Still pretty crazy looking, but if you study it you will see a patern.

  • There is a number, a pipe(|)(chr(124), and then a link.
  • If you follow the link to the end you will see a comma (,)
  • And then it starts over with a number.
  • So basically it is: XX|http://............................,XX|http://...................................,XX|http://.........................,etc.
  • So the first step is to split them at the comma(,) and toss the comma. It's just there as a delimiter and is not needed.
  • Now what is the Number before the pipe(|)
  • After a little research , I found that it is the numeric for the fmt video quality that the link points to.
  • A basic chart explaining this can be found here -->> http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
  • So now we know that the number tells us the quality of the link after the pipe (|)
  • We can toss the number and the pipe (|) and use the direct download link as needed in our script.
    I hope this helps :)
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.