Downloads with youtube-dl

Hey there folks! What’s up? Today we’re gonna talk about YouTube, the World’s largest video sharing platform. We all had some moment where there was some problem, maybe a limited data plan or weak & snail – paced data connection, that we thought to ourselves —

Wish I could download this video & watch it offline. No lags. No buffering.

progress-2888787_1280

So we got ourselves video downloaders for YouTube. But I recently jumped from the Windows ship onto the Linux ship & booked a place onto the Ubuntu Concourse. And you guessed it, I wanted to download a YouTube video. So I came across youtube-dl. youtube-dl is a command-line utility for downloading videos or extracting audio files from streaming websites such as YouTube, Dailymotion, and Vimeo, and many more.

And if you’re anything like me, the idea of a new command – line experience should get the adrenaline flowing in that cyborg body of yours. So let’s see how youtube-dl works.

Getting things started…

First we have to download youtube-dl. To do so, open up Terminal (Ctrl + Alt + T),  and type in:

sudo apt install youtube-dl

and hit enter. You will need to enter your password and then hit enter again. Remember that there is no visual feedback.

sudo stands for “Super User do” which basically means do something as a Super User. In Linux, Super User is a synonym for Admin (Root).

If you’re prompted before downloading the required packages, enter y and hit enter. The downloading will start & when complete, the installation will occur. When you’re ready at the Terminal, i.e. you see your user name at the left hand side of the terminal, then understand that the installation is complete.

New Objective: Download a video

Now, copy the link of the YouTube video that you want to download.

Now in the terminal, type:

youtube-dl -F your_video_link_here

and hit enter. Be sure to replace your_video_link_here with the actual YouTube video link. Hit Ctrl+Shift+V to paste the YouTube link into the terminal.

Screenshot from 2018-05-23 18-22-31

“-F” in the youtube-dl command in terminal lists the different formats of the YouTube video & allows you to choose from them. If you simply want to download the best quality of the video in 1-click, simply remove the “-F” from the command.

After that you can see this on terminal:

Screenshot from 2018-05-23 18-24-47

Out of this list, choose the appropriate video, & note its format code (the 1st column). For example, if you want to download the video at 720p with mp4 extension, its the last one in the list, with format code 22.

So in the terminal write:

youtube-dl -f FORMAT_CODE_HERE YOUR_VIDEO_LINK_HERE

For example if the video URL is https://www.youtube.com/watch?v=ehjJ614QfeM (this is a Witcher 3 trailer by the way. The Witcher 3 is the best game ever.), then the syntax would be:

youtube-dl -f 22 https://www.youtube.com/watch?v=ehjJ614QfeM

and hit enter. After that, the video will start downloading.

Screenshot from 2018-05-23 18-32-01

The ETA is the amount of time remaining to complete the download. When it’s complete:

Screenshot from 2018-05-23 18-35-18

youtube-dl saves videos by default in the current working directory. So basically if you opened Terminal from the desktop dock the video is saved in:

/home/your_username_here

To check where the video is saved, type:

pwd

in the terminal and hit enter. Then simply navigate to that directory. In my PC, it was saved in the home folder (/home/gourab):

Screenshot from 2018-05-23 18-42-29

So if you want to download videos to your Videos (or any other folder), simply right click on it & click launch in Terminal:

Screenshot from 2018-05-23 18-53-06

Then follow the steps to download the video. It will download to this folder because now its the pwd (Present Working Directory).

DLC Extras

  • To cancel a download at any time, press Ctrl + C.
  • To download  a playlist the syntax is:
youtube-dl --yes-playlist PLAYLIST_URL_GOES_HERE

Screenshot from 2018-05-23 19-49-45

The best qualities of all the videos will be automatically chosen from and downloaded.

  • To download a video along with actual subtitles uploaded by owner:
youtube-dl --write-srt --sub-lang en VIDEO_URL_GOES_HERE

screenshot-from-2018-05-23-19-12-42.png

  • To download actual subtitles of a video without downloading the actual video:
youtube-dl --write-srt --sub-lang en --skip-download VIDEO_URL_GOES_HERE

Screenshot from 2018-05-23 19-20-43

The subtitle is saved in the pwd (Present Working Directory).

  • To download auto-generated subtitles along with actual videos on YouTube:
youtube-dl --write-auto-sub VIDEO_URL_GOES_HERE

Screenshot from 2018-05-23 19-28-00

  • To download auto-generated subtitles without the actual video:
youtube-dl --write-auto-sub --skip-download VIDEO_URL_GOES_HERE

Well, that was most of the important stuff about youtube-dl. Did I miss something? Or have something to add of your own? Open up in the comments section. Let’s chat.

Peace.

warning-symbols-danger… Oh and one last thing, it’s against YouTube’s policies to download videos from the platform. Wink! 😉

 

Article published on: 23-May-2018, 7:55 PM IST.

Leave a comment

search previous next tag category expand menu location phone mail time cart zoom edit close