Submitted by sudo moderator in freeAsInFreedom (edited )

Update: /u/Jorgesmule has pointed out that youtube-dl can run proprietary Javascript. They recommend using avideo instead.

Last week's thread.

This week's Free Software Application of the Week is youtube-dl, a public domain application that downloads Youtube videos.

Youtube-dl is one of the kings. This is one of those programs that exists to do only one thing, and it does that thing really damn well. Downloading videos from video sharing websites is a very common need; one for which numerous applications and web applications have been developed.

But all of the other ones are shit.

Well, the ones that I've tried, anyways. The major one I'm talking about is DVDVideoSoft's heaping pile of dogshit known as Free Youtube Download. Why is it a heaping pile of dogshit? Well, it's proprietary, but that's not the only reason. It also used to display ads in the program, install unwanted toolbars and adware, and it still does bug you to upgrade to the paid version. Sadly, due to their SEO and marketing, this is the one that most people use. There are some other free online services, but these don't have that many options, and some of them recompress the video.

Youtube-dl doesn't do any of that bullshit. You give it a URL, and it downloads the video. It's as simple as that.

Of course, if you want it to do something extra, it can. For example, if you only want to download the audio, you can pass it the -x option, and it will do that. There are a lot of options like this; probably more than you'll ever need. The ones that I've found to be useful are -F, which lists all of the formats and resolutions you can download the video in; and -f, which lets you specify which format you want to download (usually -f 43 is a good choice, if the default resolution takes too long to download).

In addition, youtube-dl lets you specify a config file. This can be at /etc/youtube-dl.conf for a global config file, or ~/.config/youtube-dl/config for the user-specific one. This is just a list of options that you want applied every time you run youtube-dl. For me, I put down these two:

--proxy socks5://127.0.0.1:9150
-o %(title)s.%(ext)s

The first one routes all of youtube-dl's traffic through Tor Browser. The second one changes the way that youtube-dl writes filenames. If you give youtube-dl this URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ, normally it will save the file as the title of the video, followed by a hyphen and dQw4w9WgXcQ. This second option eliminates that junk from the end of the URL, so that youtube-dl makes the filename the exact same as the title of the video. If this annoyed you before, then try this option out.

It's worth mentioning that youtube-dl works for more video sharing sites than Youtube. Some noteable ones are Vimeo, Dailymotion, and LiveLeak. It can also download from audio websites, such as Soundcloud and Bandcamp. To see every website youtube-dl can download from, run youtube-dl --list-extractors (warning: lots of them are porn websites). It also contains a generic extractor, which can sometimes download a video from a website that doesn't have a specific algorithm programmed just for it.

I think youtube-dl is even more useful than the developers originally intended, because it makes Youtube accessible to those who block javascript, whether that be for privacy reasons or because of nonfree code (or both). It would be easy to say "Just use a different video sharing website," if not for the network effect (everyone already uses Youtube, so it would be hard to move them all to another website). For this reason, youtube-dl is a godsend.

So it's really unfortunate that youtube-dl is as unknown as it currently is. Youtube-dl was created in 2006. The fact that I only learned of its existence a couple of years ago when I started getting into free software shows how little known it is. For something as useful as this, it really deserves better.

One other thing I want to mention is that updates to youtube-dl come in really quickly. Youtube is notorious for changing its UI once every few months, which can sometimes break the previous HTML parsing algorithm to download videos. Whenever this happens, the youtube-dl dev(s) usually send out an update within a week. So, props to them for being so speedy.

That's all that I have to say about it. Hopefully I've made someone's life a little bit easier by introducing them to this program. If you've already used youtube-dl before reading this, then you already know how good it is.


That's all for this week's Free Software Application of the Week. Join me again next Monday, for a review of Inkscape!

21

Comments

You must log in or register to comment.

lambda wrote

The very first I ever heard of youtube-dl was due to mpv, the free software video player. By default, it pulls in youtube-dl as a dependency so you can stream videos from sites straight from mpv rather than needing to download them if unnecessary (e.g., watching a video without all the BS javascript and malware).

The frequent updates are great for sites other than youtube, too. This also helps for circumventing draconian copy protection or shitty Flash players that still exist.

4

sudo OP wrote

Mpv can do that? I've been downloading them from Youtube this whole time. I'll have to try that out, but I don't know if my internet connection is fast enough to stream them. Do you just pass the Youtube URL right into mpv?

2

lambda wrote

Yeah, just use the full URL as an argument. I think VLC supports some video sites, too, but I'm not sure if it uses youtube-dl.

3

cal wrote

Are you sure it doesn't use quvi?

2

NEOalquimista wrote

Very nice (: I think it's worth mentioning that some distros don't push updates to youtube-dl very often. One of them is Ubuntu. So if it's not working properly for you, try to get youtube-dl from another source, such as a PPA. I use this one from webup8.org.

If anyone knows of a Snap package, Flatpak or anything else safer than PPAs, I'll be glad. Perhaps Python's "pip" is okay?

3