index padded

This commit is contained in:
Jesse Bannon 2022-09-25 11:03:27 -07:00
parent c29b5b6a3e
commit 6f27340670
4 changed files with 17 additions and 7 deletions

View file

@ -50,9 +50,7 @@ class YoutubePlaylistDownloaderOptions(YoutubeDownloaderOptions):
return self._playlist_url
class YoutubePlaylistDownloader(
YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubeVideo]
):
class YoutubePlaylistDownloader(YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubeVideo]):
downloader_options_type = YoutubePlaylistDownloaderOptions
downloader_entry_type = YoutubeVideo

View file

@ -163,9 +163,8 @@ class EntryVariables(BaseEntryVariables):
int
Playlist index if it exists, otherwise returns ``1``.
Note that for channels/playlists, an index of 1 implies it's the most recent
uploaded entry. It is recommended to not use this unless you know the channel/playlist
will never add new content, i.e. a music album.
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
this value change. Use with caution.
"""
return self.kwargs_get(PLAYLIST_INDEX, 1)
@ -179,6 +178,16 @@ class EntryVariables(BaseEntryVariables):
"""
return _pad(self.playlist_index, width=2)
@property
def playlist_index_padded6(self: Self) -> str:
"""
Returns
-------
str
playlist_index padded six digits.
"""
return _pad(self.playlist_index, width=6)
@property
def playlist_count(self: Self) -> int:
"""
@ -186,6 +195,9 @@ class EntryVariables(BaseEntryVariables):
-------
int
Playlist count if it exists, otherwise returns ``1``.
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
this value change. Use with caution.
"""
return self.kwargs_get(PLAYLIST_COUNT, 1)

View file

@ -72,4 +72,3 @@ class YoutubeVideoVariables(EntryVariables):
The sanitized artist name.
"""
return sanitize_filename(self.artist)

View file

@ -91,6 +91,7 @@ def mock_entry_to_dict(
"webpage_url": webpage_url,
"playlist_index": 1,
"playlist_index_padded": "01",
"playlist_index_padded6": "000001",
"playlist_count": 1,
"playlist_max_upload_year": 2021,
"playlist_max_upload_year_truncated": 21,