23

I am trying to download a complete playlist in youtube, while downloading i want to enter serial number while downloading in front of the title of the video,

For example if a playlist has a videos:

A.mp4
E.mp4
K.mp4
C.mp4
B.mp4

I want it to be

1. A.mp4
2. E.mp4
3. K.mp4
4. C.mp4
5. B.mp4.

I tried commands like:

i=0;youtube-dl -cti https://www.youtube.com/playlist?list={(Any Playlist)} -o "{{$i++}%(title)s.%(ext)s}"

but its giving me this error:

youtube-dl: error: using output template conflicts with using title, video ID or auto number

Also, Downloading the whole playlist and then renaming one by one is also not i am searching.

Is there any command which downloads the playlist and renames each video side by side according to my wish?

boop
  • 7,413
  • 13
  • 50
  • 94
Desmnd
  • 440
  • 1
  • 3
  • 14

6 Answers6

33

Sometimes I had headache to rename and sort the files based on the order.

So to add auto-numbering, use -A like,

youtube-dl https://www.youtube.com/playlist?list=PLOU2XLYxmsILe6_eGvDN3GyiodoV3qNSC -A

Or to keep playlist index,

youtube-dl -o '%(playlist_index)s. %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLOU2XLYxmsILe6_eGvDN3GyiodoV3qNSC

This will add nice numbering to the downloaded files.

And if you are downloading files which is not in playlist, you can add numbers manually to the file,

youtube-dl -o "1-%(uploader)s%(title)s.%(ext)s" https://youtu.be/862r3XS2YB0

Here I have manually added 1- to the filename while downloading.

Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132
  • Just saying, -A option is deprecated, now it is recommended to use -o. – Eray Erdin Sep 08 '17 at 18:07
  • What if you already downloaded a terabyte long playlist and now what to rename the file accordingly? ;) youtube-dl can download playlist metadata, but how to get this metadata in a form that can be used from a script to match already downloaded files and rename them? – Andrew Savinykh Jan 02 '19 at 20:32
8

Use youtube-dl -o '%(playlist_index)s. %(title)s.%(ext)s' https://www.youtube.com/playlist?list=....

dstftw
  • 2,941
  • 2
  • 16
  • 10
  • 1
    Sir, thank you it worked but you added playlist index, what if I have to add my own number in front instead the playlist index, what shall I do? – Desmnd Sep 26 '15 at 05:27
4

The best solution I found is:

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" <playlist_link>

For example:

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" https://www.youtube.com/playlist?list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ
Zoe
  • 27,060
  • 21
  • 118
  • 148
Raja Parivesh
  • 588
  • 6
  • 12
1
'outtmpl': 'temp/' + str(i) +'.%(ext)s' 
Zoe
  • 27,060
  • 21
  • 118
  • 148
Mike Gao
  • 41
  • 5
0

you have to put the youtube link in the quotes ""

example

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" "https://www.youtube.com/watch?v=ZNObiptSMSI&list=PL08903FB7ACA1C2FB"
Zoe
  • 27,060
  • 21
  • 118
  • 148
0

This is what I have been using lately.

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" -f best "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Raghav
  • 31
  • 2