youtube-dl: Video and Audio Download

YouTube-dl is a command-line program to download videos from YouTube.com and other video sites. We will look into it’s basic usage.

Instalation

sudo pip install --upgrade youtube-dl

or

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

Upgrade

sudo -H pip install --upgrade youtube-dl

Download video

youtube-dl https://www.youtube.com/watch?v=XXXXXX

Download video with referrer

youtube-dl https://player.vimeo.com/video/XXXXX --referer https://XXX 

Download subtitles

youtube-dl https://www.youtube.com/watch?v=XXXXXX --write-sub --sub-format "srt"

Install audio extractor

sudo apt-get install -y libav-tools

or

sudo apt-get install ffmpeg

Download audio only

youtube-dl -x --audio-format "mp3" https://www.youtube.com/watch?v=XXXXXX

List of options in Python