Open ljubex opened 4 years ago
I looked into this a bit, I believe it may be tricky to fix because when downloading partial playlists we do not know the total length of the playlist because ie_entries
is a generator.
Of course we could convert the whole generator into a list, and then slice it after that, in order to get the total playlist length, but I'm not familiar enough with the codebase atm to know whether this would lead to too much unnecessary processing and/or network calls.
But all the information is there, right? I mean, it's already working when downloading the full list (string length is correctly determined). In this case the list length is calculated as what's remaining. So, when calculating the string length, instead of using just "list length", it should be "list length + index" instead.
Haven't looked at the code yet though :)
Yes for your specific case (when --playlist-start
alone is set) it is possible, as you say you can do something like list length + index. The actual code I came up with to replace template_dict['n_entries']
here was
template_dict['playlist_index'] + template_dict['n_entries'] - self._num_downloads
This would give the full length of the playlist, e.g. for video 79 it would be 79 + 69 - 1 = 147.
However this would not work in other cases, e.g. --playlist-start 79 --playlist-end 82
. In this case template_dict['n_entries'
is only 4, so while we have the correct playlist_index
, we have no way of knowing the total number of entries in the playlist.
That's why I think in order to fix this properly it would have to be done in the bit of code I linked to in my previous comment.
Well, it really depends what you want to dictate the string length. To me it makes perfect sense to have string of a length of 3, even if you're picking indices from 79 to 82 (because the whole list has 147 items).
For example, file names associated with indices 79 - 82 will be named the same, no matter whether I download the whole list, or I just pick indices 79 - 82. I'd personally prefer that behavior.
Use case: I download the whole list first. Then tomorrow I just re-download few items. I'd like that new files are formatted the same.
But again, that's just a personal preference :)
Yes exactly, I agree that in the 79-82 case we want a string length of three because the total number of videos is 147. But there is no way for the code to know the total number of videos in the playlist at the point it calculates the string length, because all it knows is that it is downloading 4 videos with indices 79-82. Therefore for all it knows the total number of videos in the playlist could be 99, 999 or 9999 etc.
Checklist
Verbose log
Description
When downloading whole playlist, the length of the string that holds the index is calculated based on total number of items in the list.
For example, if I download the list above, the indices will be named: 001, 002, 003, etc (the size of three).
But if I continue from somewhere in the middle (like 79 in the example), the length of the index string will be calculated based on the number of remaining items in the list, not the total number.
So instead of 079, 080, 081, I'm getting 79, 80, 81....