How to use youtube-dl to download videos in Linux
I know you have seen how to download the YouTube video. However, most of those tools use graphical user interfaces. I will show you how to use youtube-dl to download YouTube videos through a terminal.
Youtube-dl
Youtube-dl is a Python-based command line tool that allows you to download videos from YouTube.com, Dailymotion, Google Video, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles, and other similar websites. It is written in pygtk and runs with a Python parser. It does not have strict platform requirements. It can run on Unix, Windows, or Mac OS X.
Youtube-dl supports resumable upload. If youtube-dl is killed during the download process (for example, Ctrl-C or the network connection is lost), you only need to use the same YouTube video URL to run it again. As long as there are some downloaded files in the current directory, it will automatically restore incomplete downloads, that is, you do not need to download the manager to resume the download.
Install youtube-dl
If you are running the Ubuntu-based Linux release, you can use the following command to install it:
sudoapt-get install youtube-dl
For any Linux release, you can use the following command line to quickly install youtube-dl on your system:
sudowget https://yt-dl.org/downloads/latest/youtube-dl -O/usr/local/bin/youtube-dl
After obtaining the file, you need to set the executable permission for the script to run properly.
sudochmod a+rx /usr/local/bin/youtube-dl
Use youtube-dl to download the video:
To download a video file, run the following command. "VIDEO_URL" is the url of the video you want to download.
youtube-dl VIDEO_URL
Download YouTube videos in multiple formats:
Currently, YouTube videos have different resolutions. First, you need to check the available video formats of the specified YouTube video. You can use the "-F" option to run youtube-dl. It will show you available formats.
youtube-dl -F http://www.youtube.com/watch?v=BlXaGWbFVKY
Its output is similar:
Setting language
BlXaGWbFVKY:Downloading video webpage
BlXaGWbFVKY:Downloading video info webpage
BlXaGWbFVKY:Extracting video information
Available formats:
37: mp4 [1080×1920]
46: webm [1080×1920]
22: mp4 [720×1280]
45: webm [720×1280]
35: flv [480×854]
44: webm [480×854]
34: flv [360×640]
18: mp4 [360×640]
43: webm [360×640]
5: flv [240×400]
17: mp4 [144×176]
Select one of the available video formats. For example, if you want to download the MP4 format, you can:
youtube-dl -f 17 http://www.youtube.com/watch?v=BlXaGWbFVKY
Use youtube-dl to download Video Subtitles
First, check whether there are available video subtitles. Use the following command to list all available subtitles of a video:
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
Download all subtitles, but not videos:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
Download the entire playlist
Run the following command to download the entire playlist. "Playlist_url" is the url of the playlist you want to download.
youtube-dl -cit playlist_url
Youtube-dl is a multi-functional command line tool that provides many features. No wonder this command line tool is so popular.
Via: http://itsfoss.com/download-youtube-linux/
Author: alimiracle Translator: ictlyh Proofreader: wxy
This article was originally translated by LCTT and launched with the Linux honor in China
This article permanently updates the link address: