I wanted to download youtube playlists and I decided to use youtube-dl on my Ubuntu instance. I thoguht of writing this article considering that some of the facts I found are useful for you also.
youtube-dl is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is not platform specific.
To download a playlist, simply run the following command. Where “playlist_url” is the URL of the playlist that you want to download.
#youtube-dl -cit <playlist_url>
In order to download the playlist, I used the below command.
#youtube-dl -cit 'https://www.youtube.com/watch?v=_7OwE7twvfQ&list=PLPw0KKt6G-I9LjQ58tZon1w-UUdI1gNz0'
Alternatively, you can just use the playlist ID:
#youtube-dl -cit PLPw0KKt6G-I9LjQ58tZon1w-UUdI1gNz0
Some of the useful switches when using youtube-dl to download contents.
-i, --ignore-errors Continue on download errors, for example to skip unavailable videos in a playlist
--geo-bypass Bypass geographic restriction via faking X-Forwarded-For HTTP header (experimental)
--playlist-start NUMBER Playlist video to start at (default is 1)
--playlist-end NUMBER Playlist video to end at (default is last)
-r, --limit-rate RATE Maximum download rate in bytes per second (e.g. 50K or 4.2M)
-R, --retries RETRIES Number of retries (default is 10), or "infinite".
-f, --format FORMAT Video format code, see the "FORMAT SELECTION" for all the info
-x, --extract-audio Convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)
--audio-format FORMAT Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "best" by default; No effect without -x
--audio-quality QUALITY Specify ffmpeg/avconv audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)
In a shell, & is a special character, advising the shell to start everything up to the & as a process in the background. To avoid this behavior, you can put the URL in quotes.
These days YouTube videos have different resolutions, you first need to check available video formats of a given YouTube video. For that run youtube-dl with “-F” option. It will show you a list of available formats.
#youtube-dl -F <video_url>
Its output will be like:
Setting language
BlXaGWbFVKY: Downloading video webpage
BlXaGWbFVKY: Downloading video info webpage
BlXaGWbFVKY: Extracting video information
Available formats:
37 : mp4 [1080x1920]
46 : webm [1080x1920]
22 : mp4 [720x1280]
45 : webm [720x1280]
35 : flv [480x854]
44 : webm [480x854]
34 : flv [360x640]
18 : mp4 [360x640]
43 : webm [360x640]
5 : flv [240x400]
17 : mp4 [144x176]
Now among the available video formats, choose one that you like. For example, if you want to download it in MP4 version and 1080 pixel, you should use:
#youtube-dl -f 37<video_url>
If you just want to download the audio from a YouTube video, you can use the -x option to simply extract the audio file from the video.
#youtube-dl -x <video_url>
The default file format is Ogg which you may not like. You can specify the file format of the audio file in the following manner:
#youtube-dl -x --audio-format mp3 <video_url>
If you want to update youtube-dl, you can use the below command. However pip should be installed in your Utube instance.
#sudo pip install --upgrade youtube_dl
The above steps will install latest version of youtube-dl that can be checked using youtube-dl --version. As of now the output of youtube-dl --version is:
I hope this article helped you to download YouTube videos on Ubuntu. If you have questions or suggestions, please drop a comment below.
Download Youtube Playlists in Ubuntu
June 12, 2020 / by Kushan Sharma / with No comments /
Related Posts:
Reset mysql root Password I wanted to reset the mysql root password of one of my temporary hosted mysql database server. Since it was not used for a long period of time, I coul… Read More
Change Screen Resolution of Ubuntu 12.10 Server Running on Oracle Virtual BoxHello, I was having problem of changing the resolution of the console of Ubuntu 12.10 Server (64bit) version, running on Oracle Virtualbox environmen… Read More
Disable Guest Account on Ubuntu 12.10I wanted to disable the "Guest" account on Ubuntu 12.10. A guest account allows anyone to use the computer without login credentials. No username or p… Read More
Ubuntu 12.10 - Wifi Network was not DetecetedI was experiencing a problem in configuring a Toshiba laptop for wireless access. It did not identified avaialable wireless networks. First to check … Read More
Security Vulnerabilities: Oracle GlassFish Server Administration Console Authentication BypassDescription: When the server is vulnerable to Oracle GlassFish Server Administration Console GET Request Authentication Bypass, it fails to enforce au… Read More
0 comments:
Post a Comment