Wanna download a YouTube video?

If you want to download a YouTube video it is really easy with the shell. All you have to do is to pick up the video_id in the URL and feed it to the script. It will then fetch the valid URL to download the flv video.

But that's not why I want to blog about it because there are already scripts to download YouTube videos. The reason I'm blogging is because it is a one-liner.

wget "http://www.youtube.com/get_video?`wget -q -O - "http://youtube.com/watch?v=$1" | egrep -m1 -o 'video_id=[^&]+&l=[0-9]+&t=[^"&]+'`" -O $1.flv

Note: $1 is the video_id parameter sent to the script.

Download the script.


  1. The egrep has evolved since the time of that post :

    egrep -m1 -o 'video_id=[^&]+&l=[0-9]+&sk=[^&]+&fmt_map=[^&]+&t=[^"&]+'

    And a less strict regex would be 'video_id=.*&t=[^"&]+'

  2. Great! It sounds good. Thanks for sharing.. youtube promotion packages