Youtube-dl is a brilliant small command-line program (for Linux) which enables quick and simple downloading of videos from YouTube and a several more sites (eg Facebook, Twitter, Vimeo, NBC, ABC, CNN, FOX NEWS, etc, see supported sites). It can even convert the videos to MP3’s within a single command.
To download directly from youtube-dl’s repository, open a terminal and type and execute the following command (you can copy and paste), then press Enter:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
Then execute this command in your Terminal (to grant you permission to use it):
sudo chmod a+rx /usr/local/bin/youtube-dl
Downloading videos with youtube-dl
Youtube-dl is now installed on your system and you can download a video from YouTube (or elsewhere) by typing youtube-dl in a terminal, followed by a space and then the URL of the video. For example:
You will find the resulting video in whichever directory your terminal was in when you downloaded it, which, if you’ve just opened your terminal, will usually be your home folder. If you want to download a film directly into your Videos directory, you should change the directory in your terminal (eg:
cd Videos) before downloading.
Convert YouTube videos to audio on-the-fly
If you want to extract the audio from a YouTube video in the form of an mp3, you can do this while downloading by adding a few options within the command. For example:
youtube-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=f0LUh2TK-fs
Updating youtube-dl . . . very important!
Because of the way it installs independently, youtube-dl does not update along with other programs in your system. You will know when it needs updating because it will error when you try to use it to download a video from YouTube !! Remember this!! However, updating is simple. Just type
sudo youtube-dl -U in your terminal and it should be fixed.
Be careful – case is very important when using the Terminal: -U and -u will do very different things!
More you-tube-dl options and commands
Youtube-dl is extremely versatile; there are loads of options which can be found at their github page here: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme.