youtube-dl is a small application written with python to download youtube provided media content like video and audio. What makes youtube-dl so popular are simple, works, and rich feature set. youtube-dl currently supports

YouTube.com,

Dailymotion

Google Video

Photobucket

Facebook

Yahoo

Metacafe

Depositfiles

brightcove.com

auengine.com

RingTV

instagram.com

Jukebox

3sat

CSpan

…

We will look in detail how to use youtube-dl provided features. youtube-dl can run Windows, Linux like Ubuntu, Fedora, Debian, Mac OS X operating systems.

Download and Install youtube-dl

youtube-dl can be installed in different ways like pip, package manager, manual download, etc. We will look most easy and recent ways.

Windows

Windows binary can be downloaded from the link below. And installed with Next-Next standard windows installation way.

http://youtube-dl.org/downloads/latest/youtube-dl.exe

Linux (Ubuntu, Debian, Mint, Kali)

Ubuntu and Debian packages can be installed with apt command like below.

$ apt install youtube-dl

Ubuntu, Debian

Linux (Fedora)

We can install youtube-dl package from the rpm repositories with the yum command for Fedora, CentOS, Red Hat like below.

$ yum install youtube-dl

Pip

Pip provides operating system independent python package and library management. By using pip youtube-dl can be downloaded like below.

$ pip install youtube-dl

Pip

Install From Shell Directly

youtube-dl is also provided as directly install from the Linux bash shell. Just download with curl or wget command like below. Also with the chmod command the youtube-dl script will be made directly executable.

$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl $ sudo chmod a+rx /usr/local/bin/youtube-dl

Help

Youtube-dl has a long help page which contains all details of its features. The help page can be listed below. We will provide -h option like below.

$ youtube-dl -h

Help

Man

Man page provides more detailed information about youtube-dl usage. Command man will only work on Linux distributions.

$ man youtube-dl

Man

Update youtube-dl

youtube-dl can be updated in different ways which is mainly related to the installation method. If we have installed with a package manager like apt, yum, or pip we should use these tools to update. If we have installed manually following command can be used to update.

$ youtube-dl --update

Download Video With Url

The most popular usage of youtube-dl is downloading videos by providing their URLs. While providing URLs to prevent bash related errors use double quote. This will download the video and save the most appropriate format to our local computer.

$ youtube-dl "https://www.youtube.com/watch?v=9KsnFWejpQg"

Download Video With Url

Download Audio

If we are only interested in the audio part and not video part -x parameter will extract audio from video. The format will be mp3 in this situation.

$ youtube-dl -x "https://www.youtube.com/watch?v=9KsnFWejpQg"

Download Audio

Download Playlist

YouTube provides videos as a playlist too where these videos are related. Youtube-dl can download playlist videos one by one like the following command.

$ youtube-dl "https://www.youtube.com/watch?v=9KsnFWejpQg&list=PLH15HpR5qRsXcnfTOLOA3yYSd0CmYwOHS"

Download Playlist

List Supported Video Formats

Youtube provides videos on different formats and resolutions. To get all formats and resolutions about a video -F option can be provided with URL like below.

$ youtube-dl -F "https://www.youtube.com/watch?v=9KsnFWejpQg"

List Supported Video Formats

Download Video As Mp4

From supported formats list select mp4 extension and intended resolutions format code.

$ youtube-dl -f 22 "https://www.youtube.com/watch?v=9KsnFWejpQg"

Download Video As Mp4

Download Video As Webm

Similar to the mp4 example WebM format code should be provided from supported video formats.

$ youtube-dl -f 247 "https://www.youtube.com/watch?v=9KsnFWejpQg"

Download Video As Webm

Download With All Subtitles

Some video service providers also provide subtitles about videos in different languages. These subtitles are low in size and can be downloaded like below.

$ youtube-dl --all-subs "https://www.youtube.com/watch?v=9KsnFWejpQg"

Download Batch File

Download file URLs can be provided from an interactive command line that we have done up to now or from a file. This file should contain links line by line like the example below.

https://www.youtube.com/watch?v=9KsnFWejpQg https://www.youtube.com/watch?v=J5g0udW223n

and downloads can be started like below.

$ youtube-dl -a mylist.txt

Download Batch File

Bandwidth Limit

Downloading video files will consume a lot of bandwidth because of the video nature. To prevent network congestion bandwidth usage limit can be set for youtube-dl like below. -r 1000 sets bandwidth as 1000 byte/second.

$ youtube-dl -r 1000 "https://www.youtube.com/watch?v=J5g0udW2jMQ"

Bandwidth Limit

Resume Even Errors

Sometimes errors occur in different ways like video not available for your country or video is deleted. By default, this type of error will stop the download, especially in the playlist download. To prevent download stopping from errors -i option is provided to ignore errors.