diff --git a/docs/presets.rst b/docs/presets.rst index 53b31e40..23768b71 100644 --- a/docs/presets.rst +++ b/docs/presets.rst @@ -98,7 +98,8 @@ Season Presets * ``collection_season_2`` * ``collection_season_3`` * ``collection_season_4`` -* ``collection_season_5`` +* ``...`` +* ``collection_season_20`` Example """"""" diff --git a/src/ytdl_sub/cli/main.py b/src/ytdl_sub/cli/main.py index 70102745..c3267fbb 100644 --- a/src/ytdl_sub/cli/main.py +++ b/src/ytdl_sub/cli/main.py @@ -40,7 +40,7 @@ def _download_subscriptions_from_yaml_files( subscriptions: List[Subscription] = [] output: List[Tuple[Subscription, FileHandlerTransactionLog]] = [] - # Load all of the subscriptions first to perform all validation before downloading + # Load all the subscriptions first to perform all validation before downloading for path in subscription_paths: subscriptions += Subscription.from_file_path(config=config, subscription_path=path) @@ -55,6 +55,7 @@ def _download_subscriptions_from_yaml_files( output.append((subscription, transaction_log)) gc.collect() # Garbage collect after each subscription download + Logger.cleanup() # Cleanup logger after each successful subscription download return output diff --git a/src/ytdl_sub/prebuilt_presets/tv_show/tv_show_collection.yaml b/src/ytdl_sub/prebuilt_presets/tv_show/tv_show_collection.yaml index 696b3a47..36306faa 100644 --- a/src/ytdl_sub/prebuilt_presets/tv_show/tv_show_collection.yaml +++ b/src/ytdl_sub/prebuilt_presets/tv_show/tv_show_collection.yaml @@ -16,6 +16,9 @@ presets: - "_plex_tv_show" - "_tv_show_collection" +#################################################################################################### +# SEASON PRESETS + collection_season_1: download: download_strategy: "multi_url" @@ -26,7 +29,7 @@ presets: collection_season_number_padded: "01" playlist_thumbnails: # Use latest_entry first, then see if YT channel artwork exists - # ONLY FOR SEASON 1! + # ONLY FOR SEASON 1! The channel artwork will be the show's artwork. - name: "{season_poster_file_name}" uid: "latest_entry" - name: "{tv_show_poster_file_name}" @@ -115,4 +118,289 @@ presets: namedseason: - tag: "{collection_season_5_name}" attributes: - number: "5" \ No newline at end of file + number: "5" + + collection_season_6: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_6_url}" + variables: + collection_season_number: "6" + collection_season_number_padded: "06" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_6_name}" + attributes: + number: "6" + + collection_season_7: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_7_url}" + variables: + collection_season_number: "7" + collection_season_number_padded: "07" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_7_name}" + attributes: + number: "7" + + collection_season_8: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_8_url}" + variables: + collection_season_number: "8" + collection_season_number_padded: "08" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_8_name}" + attributes: + number: "8" + + collection_season_9: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_9_url}" + variables: + collection_season_number: "9" + collection_season_number_padded: "09" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_9_name}" + attributes: + number: "9" + + collection_season_10: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_10_url}" + variables: + collection_season_number: "10" + collection_season_number_padded: "10" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_10_name}" + attributes: + number: "10" + + collection_season_11: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_11_url}" + variables: + collection_season_number: "11" + collection_season_number_padded: "11" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_11_name}" + attributes: + number: "11" + + collection_season_12: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_12_url}" + variables: + collection_season_number: "12" + collection_season_number_padded: "12" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_12_name}" + attributes: + number: "12" + + collection_season_13: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_13_url}" + variables: + collection_season_number: "13" + collection_season_number_padded: "13" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_13_name}" + attributes: + number: "13" + + collection_season_14: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_14_url}" + variables: + collection_season_number: "14" + collection_season_number_padded: "14" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_14_name}" + attributes: + number: "14" + + collection_season_15: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_15_url}" + variables: + collection_season_number: "15" + collection_season_number_padded: "15" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_15_name}" + attributes: + number: "15" + + collection_season_16: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_16_url}" + variables: + collection_season_number: "16" + collection_season_number_padded: "16" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_16_name}" + attributes: + number: "16" + + collection_season_17: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_17_url}" + variables: + collection_season_number: "17" + collection_season_number_padded: "17" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_17_name}" + attributes: + number: "17" + + collection_season_18: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_18_url}" + variables: + collection_season_number: "18" + collection_season_number_padded: "18" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_18_name}" + attributes: + number: "18" + + collection_season_19: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_19_url}" + variables: + collection_season_number: "19" + collection_season_number_padded: "19" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_19_name}" + attributes: + number: "19" + + collection_season_20: + download: + download_strategy: "multi_url" + urls: + - url: "{collection_season_20_url}" + variables: + collection_season_number: "20" + collection_season_number_padded: "20" + playlist_thumbnails: + - name: "{season_poster_file_name}" + uid: "latest_entry" + + output_directory_nfo_tags: + tags: + namedseason: + - tag: "{collection_season_20_name}" + attributes: + number: "20" \ No newline at end of file diff --git a/src/ytdl_sub/utils/logger.py b/src/ytdl_sub/utils/logger.py index 095c86aa..3112f918 100644 --- a/src/ytdl_sub/utils/logger.py +++ b/src/ytdl_sub/utils/logger.py @@ -197,7 +197,7 @@ class Logger: @classmethod def cleanup(cls, delete_debug_file: bool = True): """ - Cleans up any log files left behind. + Cleans up any log files left behind Parameters ---------- diff --git a/tests/unit/utils/test_logger.py b/tests/unit/utils/test_logger.py index 4117dd3a..9509b546 100644 --- a/tests/unit/utils/test_logger.py +++ b/tests/unit/utils/test_logger.py @@ -95,12 +95,28 @@ class TestLogger: assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"] # Ensure the file cleans up too - for handler in logger.handlers: - handler.close() - Logger.cleanup() assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name) + def test_logger_can_be_cleaned_during_execution(self): + Logger._LOGGER_LEVEL = LoggerLevels.INFO + logger = Logger.get(name="name_test") + + for _ in range(2): + logger.info("info test") + logger.debug("debug test") + + with open(Logger._DEBUG_LOGGER_FILE.name, "r", encoding="utf-8") as log_file: + lines = log_file.readlines() + + assert lines == [ + "[ytdl-sub:name_test] info test\n", + "[ytdl-sub:name_test] debug test\n", + ] + + Logger.cleanup(delete_debug_file=True) + assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name) + @pytest.mark.parametrize( "log_level, expected_stdout", [