Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix playlist_index's inconsistent behavior #302

Merged
merged 1 commit into from
May 6, 2021
Merged

Fix playlist_index's inconsistent behavior #302

merged 1 commit into from
May 6, 2021

Conversation

pukkandan
Copy link
Member

There are some inconsistencies in how youtube-dl and yt-dlp handles playlist_index when used with --playlist-reverse and similar options. Sometimes playlist_index is the index of the item in the actual playlist, and sometimes, it is the position of the item in the download queue, sometimes neither...

1. Normal use, we get expected results (1-10)
$ youtube-dl https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(title)s" --get-filename --playlist-end 10
01 How (and why) to raise e to the power of a matrix _ DE6
02 Why Bayes rule is nicer with odds
03 Hamming codes part 2, the elegance of it all
04 Hamming codes and error correction
05 Group theory, abstraction, and the 196,883-dimensional monster
06 The impossible chessboard puzzle
07 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
08 Intuition for i to the power i _ Lockdown math ep. 9
09 The DP-3T algorithm for contact tracing (via Nicky Case)
10 The power tower puzzle _ Lockdown math ep. 8
2. When using --playlist-start 5, we get 5-10 which is the actual index in the playlist
$ youtube-dl https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(title)s" --get-filename --playlist-start 5 --playlist-end 10
5 Group theory, abstraction, and the 196,883-dimensional monster
6 The impossible chessboard puzzle
7 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
8 Intuition for i to the power i _ Lockdown math ep. 9
9 The DP-3T algorithm for contact tracing (via Nicky Case)
10 The power tower puzzle _ Lockdown math ep. 8
3. When using --playlist-reverse, we get 1-10 which is the queue position. The index in actual playlist would have given 10-1
$ youtube-dl https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(title)s" --get-filename --playlist-end 10 --playlist-reverse
01 The power tower puzzle _ Lockdown math ep. 8
02 The DP-3T algorithm for contact tracing (via Nicky Case)
03 Intuition for i to the power i _ Lockdown math ep. 9
04 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
05 The impossible chessboard puzzle
06 Group theory, abstraction, and the 196,883-dimensional monster
07 Hamming codes and error correction
08 Hamming codes part 2, the elegance of it all
09 Why Bayes rule is nicer with odds
10 How (and why) to raise e to the power of a matrix _ DE6
4. --playlist-items 10,9,8,7,6,5,4,3,2,1. While the download queue for this is the same as (3), we get the index in actual playlist 10-1 since we didn't use --playlist-reverse
$ youtube-dl https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(title)s" --get-filename --playlist-items 10,9,8,7,6,5,4,3,2,1
10 The power tower puzzle _ Lockdown math ep. 8
09 The DP-3T algorithm for contact tracing (via Nicky Case)
08 Intuition for i to the power i _ Lockdown math ep. 9
07 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
06 The impossible chessboard puzzle
05 Group theory, abstraction, and the 196,883-dimensional monster
04 Hamming codes and error correction
03 Hamming codes part 2, the elegance of it all
02 Why Bayes rule is nicer with odds
01 How (and why) to raise e to the power of a matrix _ DE6
5. When using both --playlist-start 5 and --playlist-reverse together, he index in the playlist are 10-5 and position in queue is 1-5. But we get 5-10 which is neither...
$ youtube-dl https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(title)s" --get-filename --playlist-start 5 --playlist-end 10 --playlist-reverse
5 The power tower puzzle _ Lockdown math ep. 8
6 The DP-3T algorithm for contact tracing (via Nicky Case)
7 Intuition for i to the power i _ Lockdown math ep. 9
8 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
9 The impossible chessboard puzzle
10 Group theory, abstraction, and the 196,883-dimensional monster

To fix this inconsistency, I am making playlist_index always the position of the video in the actual playlist and adding a new field playlist_autonumber which is the position of the item in the playlist queue.

Outputs with this PR
$ yt-dlp https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(playlist_autonumber)02d %(title)s" --get-filename --playlist-end 10
01 01 How (and why) to raise e to the power of a matrix _ DE6
02 02 Why Bayes rule is nicer with odds
03 03 Hamming codes part 2, the elegance of it all
04 04 Hamming codes and error correction
05 05 Group theory, abstraction, and the 196,883-dimensional monster
06 06 The impossible chessboard puzzle
07 07 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
08 08 Intuition for i to the power i _ Lockdown math ep. 9
09 09 The DP-3T algorithm for contact tracing (via Nicky Case)
10 10 The power tower puzzle _ Lockdown math ep. 8

$ yt-dlp https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(playlist_autonumber)02d %(title)s" --get-filename --playlist-start 5 --playlist-end 10
05 01 Group theory, abstraction, and the 196,883-dimensional monster
06 02 The impossible chessboard puzzle
07 03 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
08 04 Intuition for i to the power i _ Lockdown math ep. 9
09 05 The DP-3T algorithm for contact tracing (via Nicky Case)
10 06 The power tower puzzle _ Lockdown math ep. 8

$ yt-dlp https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(playlist_autonumber)02d %(title)s" --get-filename --playlist-end 10 --playlist-reverse
10 01 The power tower puzzle _ Lockdown math ep. 8
09 02 The DP-3T algorithm for contact tracing (via Nicky Case)
08 03 Intuition for i to the power i _ Lockdown math ep. 9
07 04 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
06 05 The impossible chessboard puzzle
05 06 Group theory, abstraction, and the 196,883-dimensional monster
04 07 Hamming codes and error correction
03 08 Hamming codes part 2, the elegance of it all
02 09 Why Bayes rule is nicer with odds
01 10 How (and why) to raise e to the power of a matrix _ DE6

$ yt-dlp https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(playlist_autonumber)02d %(title)s" --get-filename --playlist-items 10,9,8,7,6,5,4,3,2,1
10 01 The power tower puzzle _ Lockdown math ep. 8
09 02 The DP-3T algorithm for contact tracing (via Nicky Case)
08 03 Intuition for i to the power i _ Lockdown math ep. 9
07 04 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
06 05 The impossible chessboard puzzle
05 06 Group theory, abstraction, and the 196,883-dimensional monster
04 07 Hamming codes and error correction
03 08 Hamming codes part 2, the elegance of it all
02 09 Why Bayes rule is nicer with odds
01 10 How (and why) to raise e to the power of a matrix _ DE6

$ yt-dlp https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos -o "%(playlist_index)s %(playlist_autonumber)02d %(title)s" --get-filename --playlist-start 5 --playlist-end 10 --playlist-reverse
10 01 The power tower puzzle _ Lockdown math ep. 8
09 02 The DP-3T algorithm for contact tracing (via Nicky Case)
08 03 Intuition for i to the power i _ Lockdown math ep. 9
07 04 Tips to be a better problem solver [Last lecture] _ Lockdown math ep. 10
06 05 The impossible chessboard puzzle
05 06 Group theory, abstraction, and the 196,883-dimensional monster

@pukkandan pukkandan changed the title Fix playlist_index and add playlist_autonumber Fix playlist_index's inconsistent behavior May 6, 2021
@pukkandan pukkandan merged commit 7172975 into yt-dlp:master May 6, 2021
nixxo pushed a commit to nixxo/yt-dlp that referenced this pull request Nov 22, 2021
Now `playlist_index` is always the position of the video in the actual playlist and `playlist_autonumber` is the position of the item in the playlist queue
This was referenced May 22, 2022
@altadr
Copy link

altadr commented Feb 3, 2024

(How) is it possible to achieve a (really and consistent)

time-related new numbering in playlists
(start numbering from the oldest video)?

That means, independent of the original numbering
related to the (often arbitrary) position in the playlist.

A new field 'timestamp_related_number'
only and directly derived from the timestamp
could be very helpful.

For playlists, but also for whole channels and whatever else...

(Backstory: After a lot of trial and error fiddling around
with --playlist-reverse, playlist_autonumber, --playlist-items, ... ,
finally achieving the desired result for one or several playlists,
but then the opposite again,
I noticed there must be a systematical error in my approach.

My fault was, expecting playlists numbered in a chronological order in youtube.

This is not the case, some are in ascending order, others descending,
and in some playlists single items fall totally out of the general time-related order,
which is causing even more confusion.

So the original numbering is arbitrary and seems not to be a valid base for chronological sorting.)

Any help appreciated,
and thank you very much for yt-dlp, it is a great tool.

@yt-dlp yt-dlp locked as off-topic and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants