Download YouTube videos and songs
10 Sep 2014
youtube-dl
allows you to download any video or song from YouTube, Vimeo, SoundCloud and 410 more sites.
youtube-dl have quickly become one of my favorite command line tools. Say goodbye to faulty browser extensions and sketchy websites, and say hello to downloading everything from any of the major video/audio sites right from your command line.1
Installation
You can download the binary on the official download page - I always choose the easier Homebrew installation:
Usage
Supported sites
Most of the leading video sites like YouTube, Vimeo, Dailymotion are supported, including a bunch of news, sports, trailers and of course porn sites. For a full list please see supported sites on GitHub.
Is your favorite site missing from youtube-dl? Then please do head over to the GitHub repo and check out the Adding support for a new site section. Open source contributors are constantly improving the tool with support for new sites.
Video formats
youtube-dl supports a long range of formats and resolutions, that are passed in the -f, --format FORMAT
parameter.
Every format has a format code that can be specified when downloading a video, including special name codes like: "best"
, "bestvideo"
, "bestaudio"
, "worst"
, "worstvideo"
and "worstaudio"
. If no specific format is specified the best quality format is chosen.
To list down all available formats for a video URL use -F, --list-formats
, the output will look like this:
Rip music from videos - YouTube songs to Spotify
In addition to the video formats, youtube-dl also supports a whole range of post-processing options. Check out the GitHub repo for a full list of options.
I primarily use the -x, --extract-audio
option to convert videos files into audio-only files - do note that the options has a couple of extra dependencies: ffmpeg
or avconv
and ffprobe
or avprobe
.
Shell alias yt
I pretty much only use Spotify for listening to music, unfortunately more obscure remixes and new releases often arenāt available for streaming through Spotify, so I end up needing an offline copy. Luckily youtube-dl supports downloading tracks from SoundCloud, where I find a lot of great new music - but as described earlier it supports extracting music from videos as one of the post-processing options.
Because I end up extracting audio from video files fairly often, Iāve created a quick little shell alias for downloading the audio from for example YouTube:
Additional parameters
Iāve mentioned a couple of the parameters for youtube-dl in this post, but it supports a ton more. All options are well documented in the options section of the README
.
One of my favorite hidden features is the ability to download your entire Watch Later playlist from YouTube or Vimeo, perfect entertainment for a long-haul flight.
Tool updates
The rate of updates to youtube-dl is very frequent, and there seems to be a lot of active contributors to the project. The original creator of the project Ricardo Garcia have long since stepped down as a maintainer, check out his post regarding the team working on it now: The fantastic youtube-dl team.
I once encountered a problem where I couldnāt download a video off YouTube because of a problem with encrypted signatures, I apparently had an old version of the tool and a simple update fixed the problem:
-
I shall avoid all talk about copyright laws and other legal implications of using this tool.Ā ↩
Update 1: Corrected small typo spotted by @soerenr, thanks!