I need to download videos from youtube using a python script. However i am unable to get the url of the video from the youtube page.
For example, given the url: http://www.youtube.com/watch?v=5qcmCUsw4EQ&feature=g-all-u&context=G2633db8FAAAAAAAAAAA
- I need to download the video as a flv or any other format. Also i need to be able to download it multiple quality.
- I tried several scripts like youtube-dl and quvi but they all give errors and dont work. Please help. It shall be deeply appreciated.
You need to parse the
flashvarsvariable of the<embed>tag that contains the video. These change around, so some experimentation may be required to find the current variable names. Roughly speaking, you’ll want to use a libraries likemechanizeto grab the HTML of the page andBeautifulSoupto parse the HTML and extract theflashvarsfield of the<embed>element. Then look around at the variables to figure out which one contains the video URL.e.g.,