Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

Download Youtube videos with wget

Date: 2007-12-06 00:00:00 -0400

Update: 2010-04-06, you may also want to read get_flash_videos

Here there is an easy way to download Youtube videos using wget.

First thing we need is the video ID which we are going to get using also wget together with grep.

First locate the page of the video you want to download, I will use for this example one showing compizfusion in action. <p class="codigo">wget -O /tmp/page.tmp http://www.youtube.com/watch?v=UHvAXLBMWGI</p>

Then using cat and grep we will get the video ID

cat /tmp/page.tmp | grep video_id=

This will be the output

var fullscreenUrl = '/watch_fullscreen?video_id=UHvAXLBMWGI&l=51&t=OEgsToPDskKBFLkte03dOnia39Rzd63j&sk=7Ayx8rGROMLJrkh6LkXj7AC&fs=1&title=CompizFusion';
var relatedVideoGridUrl = '/related_ajax?video_id=UHvAXLBMWGI&view_type=G&watch3=1&search=compiz%20linux%20ubuntu';
var relatedVideoListUrl = '/related_ajax?video_id=UHvAXLBMWGI&view_type=L&watch3=1&search=compiz%20linux%20ubuntu';

Check that you have more than one Video_id, but only the first one is the one we want, check that the others says “relatedVideo”, we do not want those ones.

Now download the video.

wget -O /tmp/video.flv 'http://www.youtube.com/get_video?video_id=UHvAXLBMWGI&l=51&t=OEgsToPDskKBFLkte03dOnia39Rzd63j&sk=7Ayx8rGROMLJrkh6LkXj7AC&fs=1&title=CompizFusion'

check out that I am sending the output to /tmp/video.flv you of course can use any other file and directory you may want, after this you can play the video with any player you usually use.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.