Merge branch 'master' into jesse/version-arg

This commit is contained in:
Jesse Bannon 2023-03-02 18:58:47 -08:00
commit 1eeee2e109
5 changed files with 314 additions and 8 deletions

View file

@ -98,7 +98,8 @@ Season Presets
* ``collection_season_2`` * ``collection_season_2``
* ``collection_season_3`` * ``collection_season_3``
* ``collection_season_4`` * ``collection_season_4``
* ``collection_season_5`` * ``...``
* ``collection_season_20``
Example Example
""""""" """""""

View file

@ -40,7 +40,7 @@ def _download_subscriptions_from_yaml_files(
subscriptions: List[Subscription] = [] subscriptions: List[Subscription] = []
output: List[Tuple[Subscription, FileHandlerTransactionLog]] = [] 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: for path in subscription_paths:
subscriptions += Subscription.from_file_path(config=config, subscription_path=path) 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)) output.append((subscription, transaction_log))
gc.collect() # Garbage collect after each subscription download gc.collect() # Garbage collect after each subscription download
Logger.cleanup() # Cleanup logger after each successful subscription download
return output return output

View file

@ -16,6 +16,9 @@ presets:
- "_plex_tv_show" - "_plex_tv_show"
- "_tv_show_collection" - "_tv_show_collection"
####################################################################################################
# SEASON PRESETS
collection_season_1: collection_season_1:
download: download:
download_strategy: "multi_url" download_strategy: "multi_url"
@ -26,7 +29,7 @@ presets:
collection_season_number_padded: "01" collection_season_number_padded: "01"
playlist_thumbnails: playlist_thumbnails:
# Use latest_entry first, then see if YT channel artwork exists # 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}" - name: "{season_poster_file_name}"
uid: "latest_entry" uid: "latest_entry"
- name: "{tv_show_poster_file_name}" - name: "{tv_show_poster_file_name}"
@ -116,3 +119,288 @@ presets:
- tag: "{collection_season_5_name}" - tag: "{collection_season_5_name}"
attributes: attributes:
number: "5" 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"

View file

@ -197,7 +197,7 @@ class Logger:
@classmethod @classmethod
def cleanup(cls, delete_debug_file: bool = True): def cleanup(cls, delete_debug_file: bool = True):
""" """
Cleans up any log files left behind. Cleans up any log files left behind
Parameters Parameters
---------- ----------

View file

@ -95,12 +95,28 @@ class TestLogger:
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"] assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
# Ensure the file cleans up too # Ensure the file cleans up too
for handler in logger.handlers:
handler.close()
Logger.cleanup() Logger.cleanup()
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name) 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( @pytest.mark.parametrize(
"log_level, expected_stdout", "log_level, expected_stdout",
[ [