You can use youtube-dl for this, and specify the playlist_index
tag in the output template.
For example:
youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" "https://www.youtube.com/watch?v=y064kgSr0gc&list=RDy064kgSr0gc"
will download all the videos in this playlist and add the index number in the order of the playlist, padded with zeroes to accommodate the length of the playlist.
The -o
flag specifies the output template.
Other useful flags for playlists are:
--playlist-start NUMBER Playlist video to start at (default is 1)
--playlist-end NUMBER Playlist video to end at (default is last)
--playlist-items ITEM_SPEC Playlist video items to download. Specify
indices of the videos in the playlist
separated by commas like: "--playlist-items
1,2,5,8" if you want to download videos
indexed 1, 2, 5, 8 in the playlist. You can
specify range: "--playlist-items
1-3,7,10-13", it will download the videos
at index 1, 2, 3, 7, 10, 11, 12 and 13.
There is also an autonumber
tag for use in the output template, which inserts a 5 digit number, in the order downloaded.