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:

Then open up your terminal and type:

wget -O deleteMeLater.tmp

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& 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 ' 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