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:
How to Turn On Sandbox Feature in Windows Defender AntivirusSandboxing is a process that runs an application in a safe environment isolated from the rest of the operating system and applications on a computer. … Read More
Cybersecurity Dos and Don'ts Your Employees Should Follow DO:Check Mark Use care when entering passwords in front of others Create and maintain strong passwords and change them ever… Read More
Common Secure Server Setups For Your Web ApplicationI have been receiving many queries from my industry peers regarding the best practice recommendations to securely deploy a web server. In many places … Read More
Ransomware for Mobile Devices on the Risep { margin-bottom: 0.1in; line-height: 120%; } In year 2016 and 2017, malware researchers have spotted a rapid growth in mobile malware including … Read More
Phishing Attacks Dos and Don’ts for Employees Phishing is a fake email, text or social media message with the intent of having you click on a link or open an attachment. By doing … Read More
0 comments:
Post a Comment