Giveaways, Technology, Smartphones, Programming and Internet


download videos from youtube (C#)

Latest code here

I had a search in Google for the code(in C#) to download videos from youtube as flv file. But i could not find one. So i thought of writing one.

From the swfArgs from the source code get the value of fmt_url_map (Example video http://www.youtube.com/watch?v=ZzkresBOxnQ)

"fmt_url_map": "18%7Chttp%3A%2F%2Fv18.lscache1.c.youtube.com%2Fvideoplayback%3Fip%3D0.0.0.0%26sparams%3D

id%252Cexpire%252Cip%252Cipbits%252Citag%252Cburst%252Cfactor%26itag%3D18%26

ipbits%3D0%26

signature%3D594CDBBFBB9F091FEC9A27AB5BF4D6B82BB02A32

.C7719537B15D9343F12FDF69D74B1D50AA4C07C4

%26sver%3D3%26expire%3D1251460800%26key%3Dyt1%26factor%3D1.25%26

burst%3D40%26id%3D67392b7ac04ec674%2C34%7Chttp%3A%2F %2Fv19.lscache3.c.youtube.com%2Fvideoplayback%3

Fip%3D0.0.0.0%26sparams%3Did%252Cexpire%252Cip%252

Cipbits%252Citag%252Cburst%252Cfactor%26itag%3D34%26

ipbits%3D0%26signature%3D65025436E8B5C24CE434758CBA3D0EEFEE54F9FE.33

E6FC06E4AED75A3CE68AC92B7725094EE00A6E%26sver%3D3%26expire%3D1251460800%26

key%3Dyt1%26factor%3D1.25%26burst%3D40%26id%3D67392b7ac04ec674%2C5%7Chttp%3A%2F%2Fv6.lscache3.c.youtube.com%2Fvideoplayback%3Fip%3D0.0.0.0%26sparams%3D

id%252Cexpire%252Cip%252Cipbits%252Citag%252Cburst%252Cfactor%26itag%3D5%26

ipbits%3D0%26signature%3D

D924DA3786E0B8187DBBC509D11A4B9E2856968B.

0E6847032937C4FD9BF3F3607524CAADA6AE424D

%26sver%3D3%26expire%3D1251460800%26key%3Dyt1%26factor%3D1.25%26burst%3D

40%26id%3D67392b7ac04ec674"

search for http and from the last occurrence take rest of the string

http%3A%2F%2Fv6.lscache3.c.youtube.com%2Fvideoplayback%3Fip%3D0.0.0.0%26sparams%3D

id%252Cexpire%252Cip%252Cipbits%252Citag%252Cburst%252Cfactor%26itag%3D5%26

ipbits%3D0%26

signature%3DD924DA3786E0B8187DBBC509D11A4B9E2856968B.

0E6847032937C4FD9BF3F3607524CAADA6AE424D%26sver%3D3%26

expire%3D1251460800%26key%3Dyt1%26factor%3D1.25%26burst%3D40%26

id%3D67392b7ac04ec674

URL decode the line
http://v6.lscache3.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%252Cexpire%252Cip%252Cipbits%252Citag%252Cburst%252Cfactor&itag=5&ipbits=0&signature=D924DA3786E0B8187DBBC509D11A4B9E2856968B.

0E6847032937C4FD9BF3F3607524CAADA6AE424D&sver=3&expire=1251460800&key=yt1&factor=1.25&burst=40&id=67392b7ac04ec674

Replace all %252 to %2
http://v6.lscache3.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cburst%2Cfactor&itag=5&ipbits=0&signature=D924DA3786E0B8187DBBC509D11A4B9E2856968B.

0E6847032937C4FD9BF3F3607524CAADA6AE424D&sver=3&expire=1251460800&key=yt1&factor=1.25&burst=40&id=67392b7ac04ec674



thats all

The above was the latest Youtube download logic, updated the code too

 I got the details from the Opera user scripts and the scripts which can be used with firefox and Greasemonkey 

 It is simple  

 Here is the working example  http://krishnan.co.in/utube/default.aspx (dead link)

 

Latest code here

And here is the code tube.zip (19.97 kb)

 

 

You can make the changes with some more validations and regular expressions

Related Posts

blog comments powered by Disqus