Download YouTube videos with youtube-dl
Today, by chance I found a program written in Python that is really incredible, its name is youtube-dl and allows you to download videos from YouTube from Linux or any other platform that supports the Python interpreter.
We must not be fooled by the name of the program, which can lead us to think that it only allows you to download videos from Yotube but it is not like that, it has a very long list of websites from which you can download videos such as Vimeo, Facebook, VK, RedTube, etc … In total there are more than 150 websites from which we can download.
The main advantage of youtube-dl is that it is multiplatform and works under any operating system that supports the Python interpreter.
In this article I will describe the process of installing youtube-dl on a VPS server with Ubuntu 12.04 operating system and I will also show how to download videos from YouTube easily and quickly .
How to install youtube-dl on Ubuntu VPS
In the official Ubuntu repositories we find the version
2012.02.27-1ubuntu0.1 which is very old, so we are going to use a Launchpad PPA repository that will facilitate the task to install the
2014.03.03-1 version (at the moment of writing the article) .
To install youtube-dl in Ubuntu we execute the following commands:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install youtube-dl
With these commands we already have youtube-dl installed, to verify it we execute the command:
And we will see that it shows us the installed version on the screen.
How to download YouTube videos with youtube-dl
Once installed we will start the program with some practical examples.
The easiest way to use youtube-dl is with the following command:
This simple command will download the version of the highest quality video and use the name of the title of the YouTube page terminated with the video identifier as the name of the video, in the case of our example the name would be:
Nuevo Sonic Dash para Android-cARtLOd79DA.mp4
I will not explain how in this article, but that you know that youtube-dl has many options to configure the output name of the download file .
If we want to download the YouTube video with a specific quality , the first thing we have to do is list the qualities available for the video with the command:
youtube-dl -F http://www.youtube.com/watch?v=cARtLOd79DA
It will show us something like:
[info] Available formats for cARtLOd79DA: format code extension resolution note 140 m4a audio only DASH audio , audio@128k (worst) 160 mp4 192p DASH video 133 mp4 240p DASH video 134 mp4 360p DASH video 135 mp4 480p DASH video 136 mp4 720p DASH video 17 3gp 176x144 36 3gp 320x240 5 flv 400x240 43 webm 640x360 18 mp4 640x360 22 mp4 1280x720 (best)
Now assuming that we want to download the mp4 version of 640 × 360 resolution , what we have to do is remember the identifier of the format that is in this case
18 and use the command:
youtube-dl -f 18 http://www.youtube.com/watch?v=cARtLOd79DA
If we have a list of videos to download, we can batch download YouTube videos with the command:
youtube-dl -a lista_enlaces_youtube.txt
Another interesting option is that it allows us to download entire YouTube channels or playlists as easily as executing the following command:
youtube-dl enlace_lista_de videos
Final notes about youtube-dl
It is a free script and we can find it on GitHub .
On the GitHub page we find all the necessary information to correctly manage the program , so it is advisable to have it at hand. One of the warnings that the programmer makes is that YouTube when you download a lot requests a verification with captcha, so there is no other option but to access through the browser and solve the captcha.
This is a somewhat cumbersome inconvenience if we are in a VPS without a graphical environment since we do not have a browser to solve the captcha, but we can always use a remote desktop with X2GO and we have everything solved.
I hope you liked the article, if you have doubts you can always use the comments and I will answer you as soon as possible.