Sunday, May 13, 2012

youtube-dl - a CLI script for downloading streaming videos

Yes, I've been lazy and negligent about updating this blog, but then, that's the story of personal blogs worldwide.

Anyway, this one's gonna be short and quick. I just found out a Python-based script youtube-dl to download youtube (and other supported) videos via command line.

You can get it here:

http://rg3.github.com/youtube-dl/

The syntax is pretty simple, once you have added executable permissions to the script (requires Python 2.5 or newer):

./youtube-dl <Web URL here>

Or you can check your official repositories for a package called 'youtube-dl'.

There're a plenty of tools/addons/websites available online, and most of my batchmates have their own versions of youtube downloaders to their credit, so why this post?

1. Apparently, with browser/OS/whatever updates, the older method of copying the streamed video from the file descriptors (/proc/*/fd/*) doesn't work.

2. This thing does not use the 'saving streamed content' concept. It *somehow* obtains a download link by itself. And it's written purely in Python. Understanding how it works could help you in clearing a lot of concepts. (Fair warning though: it's a 4500 line code, and most of the modules used are unheard of, to me. This one's not for the weak at heart.)

3. If you just wanted a method to get it done, and are least interested about the inner workings of such utilities, I'm sorry - you're looking at the wrong blog.