How to get flv url from youtube videos

4.7k views Asked by At

Hey I know this question is too old and repetitive but keeping in account of the changing nature of the youtube API and its various representational structure I would like to pose this question once more. How can I get .flv url of the video of the youtube. Please suggest me links or ways or code (java python c preferred). Thankyou

2

There are 2 answers

0
therealprashant On BEST ANSWER

Hey I got to know how to get the .flv url

Steps:

1.GOTO https://www.youtube.com/get_video_info?asv=3&el=detailpage&hl=en_US&video_id=" + videoID;

2.in the source file obtained from above step there will be a parameter

3.Access the "url" varialble of this parameter and decode it and Voila!

Please note the following link on some videos not working according to the above method https://superuser.com/a/773998

3
Zombo On

The get_video_info page is interesting. However consider the following script

function urldecode {
  awk -niord '{printf RT ? $0 chr("0x" substr(RT,2)) : $0}' RS=%..
}
curl -s 'www.youtube.com/get_video_info?el=detailpage&video_id=0KSOMA3QBU0' |
awk '/url_encoded_fmt_stream_map/ {print $2}' RS='&' FS== |
urldecode |
awk '
NR==1 {
  gsub("=", "\n")
  gsub("&", "\n\n")
  print
}
' RS=, |
urldecode

Here is the output

type
video/mp4;+codecs="avc1.64001F,+mp4a.40.2"

url
http://r15---sn-q4f7dnsd.googlevideo.com/videoplayback?ratebypass=yes&sver=3&expire=1416924562&sparams=gcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cmm%2Cms%2Cmv%2Cratebypass%2Csource%2Cupn%2Cexpire&upn=46fju6Z8Qm4&itag=22&gcr=us&key=yt5&id=o-AHo9GtJdhAeC8V2gYsFz5DB3nSacKl7ZCBp7vwMdfmyO&fexp=904845%2C907259%2C913430%2C914074%2C915516%2C927622%2C932404%2C943909%2C947209%2C947215%2C948124%2C952302%2C952605%2C952901%2C953912%2C957103%2C957105%2C957201&ipbits=0&mm=31&initcwndbps=966250&mt=1416902815&ip=99.109.97.214&ms=au&mv=m&source=youtube

quality
hd720

s
D04D0409FCFC5CFF7BF2ACD0199DCE16AB298DD22B164.EC75C05FC8EE97A55A296B53B85456E915DDBC7F7D

itag
22

fallback_host
tc.v17.cache7.googlevideo.com

If you try the URL as is, it will not work. It will only work if you include the decrypted s value.