Using wget to Download Youtube Videos

Last updated: May 27, 2008

Today I am going to show you a neat way of downloading Youtube videos using wget. Most Linux distros will come with wget. If you don’t have it, check with your distro for instructions on how to install it. Windows users can get wget here.

First locate the url of the video you want to download.

Hmmm… Here is a good one:

http://youtube.com/watch?v=eBGIQ7ZuuiU

Then open up your terminal and type:

wget -O deleteMeLater.tmp http://www.youtube.com/watch?v=eBGIQ7ZuuiU

This command will quickly download the page’s html.

Since Youtube has other flash objects and related videos we need to find the one we want. Fortunately Youtube uses the same layout for all their videos.

cat deleteMeLater.tmp | grep fullscreenUrl

This gives me the url I need for the video:

var fullscreenUrl = '/watch_fullscreen?fs=1&BASE_YT_URL=http%3A%2F%2Fyoutube.com%2F&vq=None&video_id=eBGIQ7ZuuiU&l=210&sk=QHSGy-6-eiJ6h5qtrj1kR2OJanvL6tLlC&fmt_map=&t=OEgsToPDskIjlCX_1shTRBRDv2UQzVb-&hl=en&plid=AAROOIUyvpMFnjvzAAAAoARsYAg&tk=6J3d54cPnMJP7mUN2BtMkd2OmbgxTvB_GPcrV3ckGUbzd7KVMiH1kA%3D%3D&title=Rick Roll';

We are mostly interested in the video_id= portion of the URL. Finally, to download the video we can use:

wget -O rickroll.flv 'http://www.youtube.com/get_video?video_id=eBGIQ7ZuuiU&l=210&sk=QHSGy-6-eiJ6h5qtrj1kR2OJanvL6tLlC&fmt_map=&t=OEgsToPDskIjlCX_1shTRBRDv2UQzVb-&hl=en&plid=AAROOIUyvpMFnjvzAAAAoARsYAg&tk=6J3d54cPnMJP7mUN2BtMkd2OmbgxTvB_GPcrV3ckGUbzd7KVMiH1kA%3D%3D&title=Rick Roll'

You can change the file name rickroll.flv to anythingYouWant.flv. Wget will save the .flv (flash video) in the current directory.

Need to print shipping labels on your site?

Checkout my product RocketShipIt for simple easy-to-use developer tools for UPS™ FedEx™ USPS™ and more.

Get notified on new posts or other things I'm working on

Share: