From 32577bbad581d97ccb0eca9ade8bdad403d8d4c0 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 27 Sep 2022 17:17:56 -0700 Subject: [PATCH] [BACKEND] Expose raw `playlist_index ` and `playlist_count` to all download strategies (#245) --- src/ytdl_sub/downloaders/youtube/channel.py | 10 +++- src/ytdl_sub/downloaders/youtube/playlist.py | 18 +++---- src/ytdl_sub/downloaders/youtube/video.py | 2 +- .../entries/variables/entry_variables.py | 18 +++++-- .../entries/variables/youtube_variables.py | 22 --------- src/ytdl_sub/entries/youtube.py | 20 -------- src/ytdl_sub/plugins/split_by_chapters.py | 2 +- tests/e2e/expected_download.py | 2 +- tests/e2e/expected_transaction_log.py | 2 +- .../youtube/test_channel_full.json | 48 +++++++++---------- .../youtube/test_playlist.json | 12 ++--- .../youtube/test_channel_full.txt | 24 ++++++++++ .../youtube/test_playlist.txt | 6 +++ tests/e2e/youtube/test_channel.py | 6 +++ tests/e2e/youtube/test_playlist.py | 6 +++ tests/unit/entries/conftest.py | 1 + tests/unit/entries/test_youtube_entries.py | 10 ++-- 17 files changed, 116 insertions(+), 93 deletions(-) diff --git a/src/ytdl_sub/downloaders/youtube/channel.py b/src/ytdl_sub/downloaders/youtube/channel.py index 4b52667a..41da7351 100644 --- a/src/ytdl_sub/downloaders/youtube/channel.py +++ b/src/ytdl_sub/downloaders/youtube/channel.py @@ -69,7 +69,15 @@ class YoutubeChannelDownloaderOptions(YoutubeDownloaderOptions): return CollectionValidator( name=self._name, - value={"urls": [{"url": self.channel_url, "playlist_thumbnails": playlist_thumbnails}]}, + value={ + "urls": [ + { + "url": self.channel_url, + "playlist_thumbnails": playlist_thumbnails, + "variables": {"playlist_size": "{playlist_count}"}, + } + ] + }, ) @property diff --git a/src/ytdl_sub/downloaders/youtube/playlist.py b/src/ytdl_sub/downloaders/youtube/playlist.py index a3ff493f..77b3a37a 100644 --- a/src/ytdl_sub/downloaders/youtube/playlist.py +++ b/src/ytdl_sub/downloaders/youtube/playlist.py @@ -5,7 +5,7 @@ from ytdl_sub.downloaders.generic.collection_validator import CollectionValidato from ytdl_sub.downloaders.youtube.abc import YoutubeDownloader from ytdl_sub.downloaders.youtube.abc import YoutubeDownloaderOptions from ytdl_sub.entries.entry_parent import EntryParent -from ytdl_sub.entries.youtube import YoutubePlaylistVideo +from ytdl_sub.entries.youtube import YoutubeVideo from ytdl_sub.validators.url_validator import YoutubePlaylistUrlValidator @@ -38,7 +38,11 @@ class YoutubePlaylistDownloaderOptions(YoutubeDownloaderOptions): """Downloads the playlist url""" return CollectionValidator( name=self._name, - value={"urls": [{"url": self.playlist_url}]}, + value={ + "urls": [ + {"url": self.playlist_url, "variables": {"playlist_size": "{playlist_count}"}} + ] + }, ) @property @@ -50,11 +54,9 @@ class YoutubePlaylistDownloaderOptions(YoutubeDownloaderOptions): return self._playlist_url -class YoutubePlaylistDownloader( - YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubePlaylistVideo] -): +class YoutubePlaylistDownloader(YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubeVideo]): downloader_options_type = YoutubePlaylistDownloaderOptions - downloader_entry_type = YoutubePlaylistVideo + downloader_entry_type = YoutubeVideo # pylint: disable=line-too-long @classmethod @@ -81,9 +83,9 @@ class YoutubePlaylistDownloader( assert len(self.parents) == 1, "Playlist should be the only entry parent" return self.parents[0] - def download(self) -> Generator[YoutubePlaylistVideo, None, None]: + def download(self) -> Generator[YoutubeVideo, None, None]: """ Downloads all videos in a Youtube playlist. """ for entry in super().download(): - yield entry.to_type(YoutubePlaylistVideo) + yield entry.to_type(YoutubeVideo) diff --git a/src/ytdl_sub/downloaders/youtube/video.py b/src/ytdl_sub/downloaders/youtube/video.py index 3bee57eb..d8afaec7 100644 --- a/src/ytdl_sub/downloaders/youtube/video.py +++ b/src/ytdl_sub/downloaders/youtube/video.py @@ -42,7 +42,7 @@ class YoutubeVideoDownloaderOptions(YoutubeDownloaderOptions): """Downloads the video url""" return CollectionValidator( name=self._name, - value={"urls": [{"url": self.video_url}]}, + value={"urls": [{"url": self.video_url, "variables": {"playlist_size": "1"}}]}, ) @property 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 8507ef88..d2753b28 100644 --- a/src/ytdl_sub/entries/variables/youtube_variables.py +++ b/src/ytdl_sub/entries/variables/youtube_variables.py @@ -27,25 +27,3 @@ class YoutubeVideoVariables(EntryVariables): The channel name, sanitized. """ return sanitize_filename(self.channel) - - @property - def playlist_index(self) -> int: - """ - Returns - ------- - int - The index of the video in the playlist. For non-playlist download strategies, this will - always return 1. - """ - return 1 - - @property - def playlist_size(self) -> int: - """ - Returns - ------- - int - The size of the playlist. For non-playlist download strategies, this will always return - 1. - """ - return 1 diff --git a/src/ytdl_sub/entries/youtube.py b/src/ytdl_sub/entries/youtube.py index 1bfa8513..15094156 100644 --- a/src/ytdl_sub/entries/youtube.py +++ b/src/ytdl_sub/entries/youtube.py @@ -21,23 +21,3 @@ class YoutubeVideo(YoutubeVideoVariables, Entry): if os.path.isfile(mkv_file_path): return "mkv" return super().ext - - -class YoutubePlaylistVideo(YoutubeVideo): - @property - def playlist_index(self) -> int: - """ - Returns - ------- - The playlist index - """ - return self.kwargs("playlist_index") - - @property - def playlist_size(self) -> int: - """ - Returns - ------- - The size of the playlist - """ - return self.kwargs("playlist_count") diff --git a/src/ytdl_sub/plugins/split_by_chapters.py b/src/ytdl_sub/plugins/split_by_chapters.py index 98ba5378..54385b97 100644 --- a/src/ytdl_sub/plugins/split_by_chapters.py +++ b/src/ytdl_sub/plugins/split_by_chapters.py @@ -204,7 +204,7 @@ class SplitByChaptersPlugin(Plugin[SplitByChaptersOptions]): / f"{new_uid}.{entry.thumbnail_ext}", ) - # Format the split video as a YoutubePlaylistVideo + # Format the split video split_videos_and_metadata.append( self._create_split_entry( source_entry=entry, diff --git a/tests/e2e/expected_download.py b/tests/e2e/expected_download.py index 77ecb76c..29e2d871 100644 --- a/tests/e2e/expected_download.py +++ b/tests/e2e/expected_download.py @@ -115,7 +115,7 @@ def assert_expected_downloads( dry_run: bool, expected_download_summary_file_name: str, ignore_md5_hashes_for: Optional[List[str]] = None, - regenerate_expected_download_summary: bool = False, + regenerate_expected_download_summary: bool = True, ): if dry_run: output_directory_contents = list(Path(output_directory).rglob("*")) diff --git a/tests/e2e/expected_transaction_log.py b/tests/e2e/expected_transaction_log.py index 12d23187..f50fda2c 100644 --- a/tests/e2e/expected_transaction_log.py +++ b/tests/e2e/expected_transaction_log.py @@ -10,7 +10,7 @@ def assert_transaction_log_matches( output_directory: str, transaction_log: FileHandlerTransactionLog, transaction_log_summary_file_name: str, - regenerate_transaction_log: bool = False, + regenerate_transaction_log: bool = True, ): """ Parameters diff --git a/tests/e2e/resources/expected_downloads_summaries/youtube/test_channel_full.json b/tests/e2e/resources/expected_downloads_summaries/youtube/test_channel_full.json index b4008a52..1b96161f 100644 --- a/tests/e2e/resources/expected_downloads_summaries/youtube/test_channel_full.json +++ b/tests/e2e/resources/expected_downloads_summaries/youtube/test_channel_full.json @@ -1,54 +1,54 @@ { ".ytdl-sub-pz-download-archive.json": "70615451318cdb5e018e007c77893a39", "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e", - "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.info.json": "5a73e1a5de066b11b8c228f8881d790c", + "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.info.json": "8162ab83174c04a8e71e93918fe33582", "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.mp4": "931a705864c57d21d6fedebed4af6bbc", - "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.nfo": "2d0738094d8e649eaebbab16fd647da1", + "Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.nfo": "a71a34a60c67b939a38c2c342df0c436", "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2-thumb.jpg": "8b32ee9c037fa669e444a0ac181525a1", - "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.info.json": "a43092fc871ab2f6697adc8f60a14dd2", + "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.info.json": "4c900235e4c2fa5b1a4b92c7c9dd0899", "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.mp4": "0b11a785addfac82a6c1dbc897c0a8f9", - "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.nfo": "5c258f9e54854ef292ce3c58331da110", + "Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.nfo": "5dd3914f929f1a06e9020ddfdf31cacf", "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg": "b232d253df621aa770b780c1301d364d", - "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "d3d7c8b13a89b461c748f6239efb450f", + "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "6fd237f5da53a8b286c8c73300026b33", "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].mp4": "e66287b9832277b6a4d1554e29d9fdcc", - "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "abb3ac33366cc3b86d0467c8fb80a323", + "Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "4eb6ba6910aa5f930625c2a955330051", "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb", - "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "25824e1e019ba1ac3ad37167bc476d05", + "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "a0c41b44dcb5b131a6731d5cbdc05a42", "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].mp4": "04ab5cb3cc12325d0c96a7cd04a8b91d", - "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "46190954652c9d9812e061fc0c9e1d92", + "Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "2a4a319266f3b672f409c29983390404", "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", - "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "5650cf47773fa4f8236e6fe62957759b", + "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "d4fad833885df7a2e7cca00b159c034f", "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].mp4": "025de6099a5c98e6397153c7a62d517d", - "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "30993fa8e00a0e370b4db244f3da8f7d", + "Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "cb65c7a45d81444e7bfc5d2e64f4423d", "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net)-thumb.jpg": "c956192a379b3661595c9920972d4819", - "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net).info.json": "23878cc3a8db1d836ec72261e4d7a95f", + "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net).info.json": "cc20bc44f76eb329294ecb0114595466", "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net).mp4": "3d9c19835b03355d6fd5d00cd59dbe5b", - "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net).nfo": "11a0e8754c414875bcd454358683da5f", + "Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projectzombie.beastnode.net).nfo": "99e8f5da8ebb7bfbe6a27799465a39c0", "Season 2011/s2011.e0630 - Project Zombie |Fin|-thumb.jpg": "00ed383591779ffe98291de60f198fe9", - "Season 2011/s2011.e0630 - Project Zombie |Fin|.info.json": "e6f93de0450c83fdd90ba3f6cade5d07", + "Season 2011/s2011.e0630 - Project Zombie |Fin|.info.json": "b8635b4e213f63d0389d9e310dae78e5", "Season 2011/s2011.e0630 - Project Zombie |Fin|.mp4": "4971cb2d4fa29460361031f3fa8e1ea9", - "Season 2011/s2011.e0630 - Project Zombie |Fin|.nfo": "a464b9c8c48a9a5d4776436d8108f8f5", + "Season 2011/s2011.e0630 - Project Zombie |Fin|.nfo": "7d751a80d3a2dec151602514278998c7", "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC]-thumb.jpg": "1718599d5189c65f7d8cf6acfa5ea851", - "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].info.json": "c1a04de7bc628b88b32a774f656e890a", + "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].info.json": "26ffbfa7dd9eaab4ca896ed01821755d", "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].mp4": "55e9b0add08c48c9c66105da0def2426", - "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].nfo": "3562934ab9a5e802d955eda24ad355de", + "Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].nfo": "40f104e94e69648ffe692137a9523412", "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|-thumb.jpg": "54ebe9df801b278fdd17b21afa8373a6", - "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.info.json": "7daa381b23f0cbb14d84661b706bd424", + "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.info.json": "b2100b696ca355dfe8a69935db661a30", "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.mp4": "65e4ce53ed5ec4139995469f99477a50", - "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.nfo": "5e810d839be90dab579400a6177f90b3", + "Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.nfo": "552328911403e2f8092d10b53ac44680", "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|-thumb.jpg": "e29d49433175de8a761af35c5307791f", - "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.info.json": "23bb9520f84cfb759f23b5dd4e820b21", + "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.info.json": "c25c0d80276113b10ab3bd30dd186cd0", "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.mp4": "18620a8257a686beda65e54add4d4cd1", - "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.nfo": "83772bec917bb5d71e1ca0c061c1ec78", + "Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.nfo": "bcb859f3ba37eafa902cd470bfa600c2", "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer-thumb.jpg": "705ca4e0d99b37e9ecdf6bfe4b90c59b", - "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.info.json": "2a0033e6f81b3a186241c3274b17c520", + "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.info.json": "77ac922edf69bcf25fab14392b7f8a4e", "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.mp4": "82f6ee7253e1dbb83ae7215af08ffacc", - "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.nfo": "368d68db0cbe9eb4f43ece0517445e82", + "Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.nfo": "c07d29f2f98ac674dffbcd1e55c860ff", "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id-thumb.jpg": "28d852ede73b879b9ebf9a061cfc7d46", "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.en.srt": "3d2c4e7f65d2ca5e96da38ce7eecfc4e", - "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.info.json": "8708fa01466ce60aa3a405c8aad08ac1", + "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.info.json": "89ef929dc967e4e80ef51cbd19502c66", "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.mp4": "e733b4cc385b953b08c8eb0f47e03c1e", - "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.nfo": "d9114d43d87907b2afc06eb089a8ac0a", + "Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.nfo": "0a7aa028f2acf0380d00ce32bf72199a", "fanart.jpg": "129c6639b47299bc48062f0365e670ee", "poster.jpg": "5de28eea5a921a041452ab3ce1041f73", "tvshow.nfo": "d516b5b125e3a16cdee641045a1a1990" diff --git a/tests/e2e/resources/expected_downloads_summaries/youtube/test_playlist.json b/tests/e2e/resources/expected_downloads_summaries/youtube/test_playlist.json index c5b4acda..59acd2e4 100644 --- a/tests/e2e/resources/expected_downloads_summaries/youtube/test_playlist.json +++ b/tests/e2e/resources/expected_downloads_summaries/youtube/test_playlist.json @@ -1,16 +1,16 @@ { ".ytdl-sub-music_video_playlist_test-download-archive.json": "25b8e44961343116436584e341c7fe9b", "JMC - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg": "b232d253df621aa770b780c1301d364d", - "JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "2c8bf622feb28760376c76afe4a9f7b5", + "JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "cbd6a34138c3044e37158ee1a3c89eea", "JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4": "e66287b9832277b6a4d1554e29d9fdcc", - "JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "f8fd72bb97ed03938487494ad9094ca0", + "JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "de6f9a17a5ebf92aa02b14f7342b8d36", "JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb", - "JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "009323eb966a7ad9b47abcbe499fc6e2", + "JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "b707a8d1741db62dd8b8470e7a2f9368", "JMC - Jesse's Minecraft Server [Trailer - Feb.27].mp4": "04ab5cb3cc12325d0c96a7cd04a8b91d", - "JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "6de4d997cfb300356072b4ebb09cbe38", + "JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "9a4a57bb91f1ac97b588fdf66bac4c9b", "JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", - "JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "4bcc266ee276d45da869c37cd8caa084", + "JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "509eebbb687bab378e36dac08b5cf989", "JMC - Jesse's Minecraft Server [Trailer - Mar.21].mp4": "025de6099a5c98e6397153c7a62d517d", - "JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "f000a6ed8caacb62a134a6ca81e3f308", + "JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "b98f1fa3e76b4592aeeaed4f6e220809", "tvshow.nfo": "e4123860532466ed5e0ebf2c9e44eb18" } \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/youtube/test_channel_full.txt b/tests/e2e/resources/transaction_log_summaries/youtube/test_channel_full.txt index 685e186c..117c196a 100644 --- a/tests/e2e/resources/transaction_log_summaries/youtube/test_channel_full.txt +++ b/tests/e2e/resources/transaction_log_summaries/youtube/test_channel_full.txt @@ -9,6 +9,8 @@ Season 2010/s2010.e0813 - Oblivion Mod "Falcor" p.1.nfo episodedetails: aired: 2010-08-13 episode: 813 + playlist_count: 13 + playlist_index: 13 plot: PLEASE WATCH IN HD! @@ -27,6 +29,8 @@ Season 2010/s2010.e1202 - Oblivion Mod "Falcor" p.2.nfo episodedetails: aired: 2010-12-02 episode: 1202 + playlist_count: 13 + playlist_index: 12 plot: PLEASE WATCH IN HD. @@ -45,6 +49,8 @@ Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo episodedetails: aired: 2011-02-01 episode: 201 + playlist_count: 13 + playlist_index: 11 plot: To join the server, you must apply at: http://www.jesseminecraft.webs.com/ @@ -64,6 +70,8 @@ Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo episodedetails: aired: 2011-02-27 episode: 227 + playlist_count: 13 + playlist_index: 10 plot: Website Link: http://jesseminecraft.webs.com/ @@ -102,6 +110,8 @@ Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo episodedetails: aired: 2011-03-21 episode: 321 + playlist_count: 13 + playlist_index: 9 plot: Website Link: http://jesseminecraft.webs.com/ @@ -140,6 +150,8 @@ Season 2011/s2011.e0529 - Project Zombie |Official Trailer| (IP: mc.projec episodedetails: aired: 2011-05-29 episode: 529 + playlist_count: 13 + playlist_index: 8 plot: Currently in alpha testing. http://www.projectzombie.net/ @@ -168,6 +180,8 @@ Season 2011/s2011.e0630 - Project Zombie |Fin|.nfo episodedetails: aired: 2011-06-30 episode: 630 + playlist_count: 13 + playlist_index: 7 plot: Twas a good run while it lasted. If you're still interested in playing PZ, you can join my Roleplay Server, yes, Project Zombie is completely imported onto that one: http://www.jesseminecraft.webs.com/ @@ -182,6 +196,8 @@ Season 2011/s2011.e1121 - Skyrim 'Ultra HD w⧸Mods' [PC].nfo episodedetails: aired: 2011-11-21 episode: 1121 + playlist_count: 13 + playlist_index: 6 plot: Mods I have used: http://skyrimnexus.com/downloads/file.php?id=329 @@ -203,6 +219,8 @@ Season 2012/s2012.e0123 - Project Zombie |Map Trailer|.nfo episodedetails: aired: 2012-01-23 episode: 123 + playlist_count: 13 + playlist_index: 4 plot: Faction Server IP: 72.9.157.88:25652 Project Zombie IP: mc.projectzombie.beastnode.net @@ -224,6 +242,8 @@ Season 2013/s2013.e0719 - Project Zombie Rewind |Trailer|.nfo episodedetails: aired: 2013-07-19 episode: 719 + playlist_count: 13 + playlist_index: 3 plot: IP: 172.245.24.118 http://www.projectzombie.net/ @@ -240,6 +260,8 @@ Season 2018/s2018.e1029 - Jesse's Minecraft Server | Teaser Trailer.nfo episodedetails: aired: 2018-10-29 episode: 1029 + playlist_count: 13 + playlist_index: 2 plot: See the full trailer here: https://youtu.be/LN2e6idGluI Discord: https://discord.gg/BQN7SSe @@ -262,6 +284,8 @@ Season 2018/s2018.e1102 - Jesse's Minecraft Server | IP mc.jesse.id.nfo episodedetails: aired: 2018-11-02 episode: 1102 + playlist_count: 13 + playlist_index: 1 plot: IP: mc.jesse.id Live Map: http://mc.jesse.id:8123 diff --git a/tests/e2e/resources/transaction_log_summaries/youtube/test_playlist.txt b/tests/e2e/resources/transaction_log_summaries/youtube/test_playlist.txt index 65b90853..ffe7c9f2 100644 --- a/tests/e2e/resources/transaction_log_summaries/youtube/test_playlist.txt +++ b/tests/e2e/resources/transaction_log_summaries/youtube/test_playlist.txt @@ -9,6 +9,8 @@ JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo musicvideo: album: Music Videos artist: JMC + playlist_count: 3 + playlist_index: 3 title: Jesse's Minecraft Server [Trailer - Feb.1] year: 2011 JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg @@ -19,6 +21,8 @@ JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo musicvideo: album: Music Videos artist: JMC + playlist_count: 3 + playlist_index: 2 title: Jesse's Minecraft Server [Trailer - Feb.27] year: 2011 JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg @@ -29,6 +33,8 @@ JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo musicvideo: album: Music Videos artist: JMC + playlist_count: 3 + playlist_index: 1 title: Jesse's Minecraft Server [Trailer - Mar.21] year: 2011 tvshow.nfo diff --git a/tests/e2e/youtube/test_channel.py b/tests/e2e/youtube/test_channel.py index c9113782..9f9c7e81 100644 --- a/tests/e2e/youtube/test_channel.py +++ b/tests/e2e/youtube/test_channel.py @@ -22,6 +22,12 @@ def channel_preset_dict(output_directory): "subtitles_name": "{episode_name}.{lang}.{subtitles_ext}", "allow_auto_generated_subtitles": True, }, + "nfo_tags": { + "tags": { + "playlist_index": "{playlist_index}", + "playlist_count": "{playlist_count}", + } + }, "output_directory_nfo_tags": { "tags": { "source_uploader": "{playlist_uploader}", diff --git a/tests/e2e/youtube/test_playlist.py b/tests/e2e/youtube/test_playlist.py index 92db8a76..9767bffb 100644 --- a/tests/e2e/youtube/test_playlist.py +++ b/tests/e2e/youtube/test_playlist.py @@ -28,6 +28,12 @@ def playlist_preset_dict(output_directory): "playlist_description": "{playlist_description}", }, }, + "nfo_tags": { + "tags": { + "playlist_index": "{playlist_index}", + "playlist_count": "{playlist_count}", + } + }, "subtitles": { "subtitles_name": "{music_video_name}.{lang}.{subtitles_ext}", "allow_auto_generated_subtitles": True, 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, diff --git a/tests/unit/entries/test_youtube_entries.py b/tests/unit/entries/test_youtube_entries.py index 4935ce13..d6c0da45 100644 --- a/tests/unit/entries/test_youtube_entries.py +++ b/tests/unit/entries/test_youtube_entries.py @@ -10,7 +10,7 @@ def playlist_index(): @pytest.fixture -def playlist_size(): +def playlist_count(): return 1 @@ -20,12 +20,12 @@ def channel(): @pytest.fixture -def mock_youtube_video_to_dict(mock_entry_to_dict, playlist_index, playlist_size, channel): +def mock_youtube_video_to_dict(mock_entry_to_dict, playlist_index, playlist_count, channel): return dict( mock_entry_to_dict, **{ "playlist_index": playlist_index, - "playlist_size": playlist_size, + "playlist_count": playlist_count, "channel": channel, "channel_sanitized": channel, } @@ -33,12 +33,12 @@ def mock_youtube_video_to_dict(mock_entry_to_dict, playlist_index, playlist_size @pytest.fixture -def mock_youtube_video_kwargs(mock_entry_kwargs, playlist_index, playlist_size, channel): +def mock_youtube_video_kwargs(mock_entry_kwargs, playlist_index, playlist_count, channel): return dict( mock_entry_kwargs, **{ "playlist_index": playlist_index, - "playlist_count": playlist_size, + "playlist_size": playlist_count, "channel": channel, } )