From 6f27340670058e14b1f41002215328f14d5742ab Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sun, 25 Sep 2022 11:03:27 -0700 Subject: [PATCH] index padded --- src/ytdl_sub/downloaders/youtube/playlist.py | 4 +--- .../entries/variables/entry_variables.py | 18 +++++++++++++++--- .../entries/variables/youtube_variables.py | 1 - tests/unit/entries/conftest.py | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ytdl_sub/downloaders/youtube/playlist.py b/src/ytdl_sub/downloaders/youtube/playlist.py index bb6faf07..04c8e458 100644 --- a/src/ytdl_sub/downloaders/youtube/playlist.py +++ b/src/ytdl_sub/downloaders/youtube/playlist.py @@ -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 diff --git a/src/ytdl_sub/entries/variables/entry_variables.py b/src/ytdl_sub/entries/variables/entry_variables.py index ab8edb62..683850cb 100644 --- a/src/ytdl_sub/entries/variables/entry_variables.py +++ b/src/ytdl_sub/entries/variables/entry_variables.py @@ -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) diff --git a/src/ytdl_sub/entries/variables/youtube_variables.py b/src/ytdl_sub/entries/variables/youtube_variables.py index a42a0ddc..27d32cce 100644 --- a/src/ytdl_sub/entries/variables/youtube_variables.py +++ b/src/ytdl_sub/entries/variables/youtube_variables.py @@ -72,4 +72,3 @@ class YoutubeVideoVariables(EntryVariables): The sanitized artist name. """ return sanitize_filename(self.artist) - diff --git a/tests/unit/entries/conftest.py b/tests/unit/entries/conftest.py index b1c0cece..b797a1e3 100644 --- a/tests/unit/entries/conftest.py +++ b/tests/unit/entries/conftest.py @@ -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,