After great DrupalCon Portland I had to fly home. And it was a VERY long (10h+) transatlantic flight, so I decided to download some videos on my laptop and watch them during my flight. I could use a service like keepvid.com, but since I selected 20+ videos I needed something smarter. After a quick search I found great python script, called youtube-dl, that can download videos from YouTube and various other sources. Install on Ubuntu was straightforward:
sudo apt-get install youtube-dl
Install on other platforms should be almost as easy as this. You just need Python interpreter and script that you download from their site. There is also an executable for Windows.
In order to download videos I just needed get video's URL and this command:
youtube-dl -f 35 -t "http://youtu.be/OAjcIXqM_jQ"
- -f 35 tells I wanted to download 480p flv version (see manpage for other codes)
- -t filename of downloaded file should illustrate video's title instead of ID
- "http://youtu.be/OAjcIXqM_jQ" video's URL (script know how to follow redirects, ...)
Now I created shell script with an array of all videos that I wanted to download and loop that was running youtube-dl for each of them. Script did it's job during my last night in hotel and I was all set for my flight.