How to download YouTube playlist in Linux

Suppose you have found a favorite YouTube playlist, and want to download all videos in the playlist to play them back locally. There are several ways to download YouTube videos in a batch.

youtube-dl is one of the most powerful YouTube downloader tools available on Linux. In this tutorial, I will describe how to download YouTube playlist by using youtube-dl.

First, install youtube-dl on your Linux by following the guide here.

Next, find out the URL of the YouTube playlist that you want to download. To do so, go to the YouTube playlist page that you want, and copy the URL. The URL format of a YouTube playlist is, as shown in the screenshot below.

Now, go ahead and run the following command to download all YouTube videos in the playlist.

$ youtube-dl -citk --max-quality FORMAT

The command-line arguments used in the above command are as follows.

  • -c: resume partially downloaded video files
  • -i: continue upon download errors
  • -t: use video title as the file name
  • --max-quality FORMAT: download video in the highest quality format

If you want to download all YouTube videos in the playlist, as well as extract MP3 audio from each video file, then first install FFmpeg on your system, and run the following command.

$ youtube-dl -citk --max-quality FORMAT --extract-audio --audio-format mp3

The additional "-k" option in the above makes youtube-dl keep downloaded videos. Without this option, youtube-dl will erase downloaded video files after extracting MP3 files from them.

The following screenshot shows youtube-dl in action.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

5 thoughts on “How to download YouTube playlist in Linux

  1. awesome post. i knew about youtube-dl, but i was completely unaware about these features. :) thanx for sharing.

  2. Hi, I'm a developer of the youtube-dl project and was pointed to this page by one of our users.

    The command-line given here is unnecessarily complex and erroneous:

    * -c forces youtube-dl to resume. By default, it will do the clever thing, and will already resume most interrupted downloads.
    * -t is straight-up deprecated and has no effect whatsoever
    * While you're at it, --extract-audio can be written as -x
    * --max-quality FORMAT does not do at all what you want. By default, youtube-dl will pick the best quality already. --max-quality can be used to lower the quality. Luckily, FORMAT is not a valid format ID, at least not for any extractor I'm aware of.

    So the command-line should be simply

    youtube-dl -ix -k --audio-format mp3

    but if you have a list Id anyways, you can just pass in that, as in:

    youtube-dl -ix -k --audio-format mp3 XXXXXXXXXXX

    Note that if you want, you can edit ~/.config/youtube-dl.conf to contain options you always want, such as -i or --audio-format mp3.

  3. Thank you for both the author of the article and @Philipp Hagemeister for the suggestions. I wanted to download a large playlist of music as mp3 and was not needing video to be downloaded. so, I first ran "youtube-dl -F" (as an example) and found that "141 m4a audio only DASH audio 256k , m4a_dash container, aac @256k (44100Hz), 9.04MiB" will be suiting all the youtube videos. Then I ran the suggested comment @Philipp shown as below to download all the songs. ofcourse, .m4a files will be downloaded instead of video files. But, I can save some bandwidth without downloading large videos.
    Command: "youtube-dl -ix -k -f 141 --audio-format mp3"

    Thank You for your contributions.

Leave a comment

Your email address will not be published. Required fields are marked *