youtube-dlallows 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
You can download the binary on the official download page - I always choose the easier Homebrew installation:
# Homebrew installation (preferred) $ brew install youtube-dl # UNIX installation with curl $ sudo curl https://yt-dl.org/downloads/2014.09.06/youtube-dl -o /usr/local/bin/youtube-dl $ sudo chmod a+x /usr/local/bin/youtube-dl
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.
# List all available sites $ youtube-dl --extractor-descriptions
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.
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:
"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:
$ youtube-dl -F http://www.youtube.com/watch?v=DwYPG6vreJg [youtube] Setting language [youtube] Confirming age [youtube] DwYPG6vreJg: Downloading webpage [youtube] DwYPG6vreJg: Downloading video info webpage [youtube] DwYPG6vreJg: Extracting video information [info] Available formats for DwYPG6vreJg: format code extension resolution note 171 webm audio only DASH audio , audio@128k (worst) 140 m4a audio only DASH audio , audio@128k 160 mp4 144p DASH video , video only 242 webm 240p DASH video , video only 133 mp4 240p DASH video , video only 243 webm 360p DASH video , video only 134 mp4 360p DASH video , video only 244 webm 480p DASH video , video only 135 mp4 480p DASH video , video only 17 3gp 176x144 36 3gp 320x240 5 flv 400x240 43 webm 640x360 18 mp4 640x360 (best)
Rip music from videos - YouTube songs to Spotify
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:
# alias for youtube-dl extracting audio alias yt='youtube-dl --extract-audio --audio-format mp3'
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:
# Update youtube-dl $ youtube-dl -U
Update: Corrected small typo spotted by @soerenr, thanks!
I shall avoid all talk about copyright laws and other legal implications of using this tool. ↩