204

I'm trying to download some videos in mp3 format. It's a playlist. How do I download the whole playlist using one command?

user267628
  • 2,159
  • 2
  • 13
  • 6
  • To get the URL for a mix, right click on a song in the mix in the right column. "Copy link location" will give a url ending with &index=7. This is the kind of link which will cause [youtube:playlist] Downloading playlist .... – Paul Rougieux Apr 21 '20 at 04:24

7 Answers7

246

Both parts of this question (downloading in mp3 and downloading a playlist) are supported by youtube-dl:

youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" <url to playlist>

Some notes from me and the comments:

  • Older versions of youtube-dl struggle with modern playlists. You might need to replace the repo version with the latest.

  • cmo: You can ignore missing ("unavailable in your country", or removed) videos with an -i flag.

  • frans: If your playlist isn't working and the URL contains a v=<ID> element, remove it so there's just the ?list=... item in the querystring.

Oli
  • 293,335
  • 7
    nope it only downloaded the first video – user267628 Dec 23 '14 at 09:09
  • 5
    @user267628 I've tested this with a playlist URL and it works for me. I had to upgrade youtube-dl (see link at the end) but it sounds like your problem is you're not giving it a playlist URL. – Oli Dec 23 '14 at 09:11
  • 2
    it works perfectly for me – penta Oct 01 '15 at 19:13
  • 31
    Sometimes you copy s.th. like https://www.youtube.com/watch?v=<VIDEO_ID>&list=<LIST_ID>. I had to remove the v=<ID> part from the URL. – frans Dec 30 '15 at 13:23
  • how would i get the via commandline? I'd like to use the ytsearch feature – Jonathan Sep 12 '16 at 19:35
  • works perfectly, after updating youtube-dl (i.e. after executing youtube-dl -U). very elegant answer – cmo Feb 21 '17 at 14:00
  • 9
    I recommend you include the -i argument in the command. it will skip any videos in the playlist that have been removed from youtube – cmo Feb 21 '17 at 14:04
  • 1
    @cmo thanks for this tip. Works also to skip blocked content based on country. – devunder Jun 15 '17 at 19:01
  • Thanks for that! @frans thanks you too the tip! Worked fine after removing the v=ID part from the URL :) – Jack Aug 02 '17 at 22:46
  • https://github.com/rg3/youtube-dl/issues/698#issuecomment-212984683 to skip errors – ssi-anik Jan 01 '19 at 04:07
  • 1
    I wanted the padded track numbers as a prefix so I changed this to youtube-dl --extract-audio --audio-format mp3 -o "%(autonumber)02d-%(title)s.%(ext)s" <url to playlist> (added %(autonumber)02d-) – cfx Jan 13 '22 at 16:57
52

Note:- Old version of youtube-dl is not able to download play-list. first you know what is your youtube-dl version. To check version of Youtube-dl use command

youtube-dl --version

version 2014.02.17 and older version not able to download play-list. If you use older version then update it by

sudo youtube-dl -U

after successful update use command

youtube-dl -cit https://www.youtube.com/playlist?list=PLttJ4RON7sleuL8wDpxbKHbSJ7BH4vvCk

Also you can create URL list in a simple text file and use following command.

 youtube-dl -cit -a file_name_in_which_you_paste_URL_list

For MP3 format Audio can saved. But audio saves as .m4a format on my machine.

youtube-dl -cit --extract-audio --audio-format mp3 https://www.youtube.com/playlist?list=PLttJ4RON7sleuL8wDpxbKHbSJ7BH4vvCk

NOTE :- If you install youtube-dl from Ubuntu software center. You can't update it from terminal.
Go Software center and update from it.
I test this commands on Wine because my youtube-dl also old. And I am unable to Update it.
If you can update your youtube-dl you can download play-list by using above commands.
I hope it helps...Youtube-dl on WINE

Murmel
  • 295
Madhav Nikam
  • 2,907
12

There are a lot of instructions you can find using your favorite search engine. E.g.:

For this Playlist it would be: youtube-dl -t https://www.youtube.com/playlist?list=PLYH8WvNV1YEnNVnJb5ZXxDCE2HDAVVo4M

I hope I could help you!

6

If you installed using pip, run the following to update:

 sudo pip install youtube-dl --upgrade

Enjoy...

Snehal Parmar
  • 202
  • 2
  • 4
4

All good answers here, but let me save everyone the pain of issues when trying to download playlists.

First, you can't just download things as fast as you want. Youtube will ban your IP for awhile if you do this.

Also some playlist videos are sometimes "private" or broken, or deleted.

To avoid all these problems do this.

youtube-dl --sleep-interval 30  -i -f 251 URL_HERE

Just to add some extra clarity. You do not have to sue the -f tag with a number. You can use a specific file extension that is supported.

youtube-dl --sleep-interval 30  -i -f mp3 URL_HERE

youtube dl will always try to download the best version.

See documentation for more information - https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection

Goddard
  • 4,724
  • 2
  • 33
  • 51
  • Thanks for this suggestion. What does the 251 stand for? Is this a particular format? – Paul Rougieux Apr 20 '20 at 08:53
  • It is the format type you want to use. You don't have to use the cryptic numbers. If you just want the best and do not care about the format then you can use nothing. It will automatically download the best format it can get, but if you specifically want audio you can target a certain type.

    https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection

    – Goddard Apr 20 '20 at 18:07
  • Thanks, that link says "youtube-dl uses -f bestvideo+bestaudio/best as the default format selection ", I guess it makes sens to use -f 'worstvideo,bestaudio' to download sound files. – Paul Rougieux Apr 21 '20 at 04:21
4

an additon to Oli 's answer. If you have the playlist (in separate lines) with all URLs in it in a text file to download:

youtube-dl --extract-audio --audio-format mp3 --batch-file="/full/path/to/playlist"
aFoP
  • 336
  • 1
  • 5
3

Are you really sure you want MP3? A lot of devices nowadays can play AAC and some can even play Opus.

If you want to retain highest quality (Opus 160 kbps) and your player supports Opus codec it's better to use:

youtube-dl -f 251 (Playlist URL)

But if your player only supports AAC (as most entry-level TVs in 2018):

youtube-dl -f 140 (Playlist URL)

If you use MP3 you'll get degraded quality as reencoding (from already reencoded audio by YouTube) will be required.