Downloading YouTube movie clips to your local hard drive
I tried to watch this YouTube clip the other day but found that my flash player had a hard time synching the audio and video. Very annoying! And as far as I can see YouTube doesn’t provide a download link to let me download the movie and play it directly from my hard drive. I really wanted to see this clip but couldn’t stand the audio lagging behind. I figured there must be a way to hack that flash thing they are using to play the movie. It turned out to be quite easy!
First I downloaded the flash animation embedded in the page. You’ll find the URL of the SWF file in the text field labelled Embed to the right of the movie or you could have a look at the page’s HTML code. Then I used
wget to download this URL:
Watching the output from
wget one can see that this URL actually does a redirect to another URL:
wget downloaded the
p.swf file (this is a flash animation file) I used flare to decompile it and had a look at the ActionScript code. The code had a number of URL strings and after reading Macromedia’s docs on the NetStream class I knew I had found the URL I was looking for. Here’s how I downloaded the movie above which I wanted to watch:
t parameter comes from the redirect URL we got as a response to the first
wget. This appears to be some kind of ticket or something and seems to change over time.
After executing this
wget command I had an FLV movie file on my hard drive which I could watch using mplayer without any audio problems!