Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Wrong string length for playlist index, when using --playlist-start #24893
Comments
|
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 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 template_dict['playlist_index'] + template_dict['n_entries'] - self._num_downloadsThis 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. 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....