From 3d870805d1d5c6674db1de6bfcb34b65159fdc0a Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 5 Jan 2023 16:33:21 -0500 Subject: [PATCH] [5] allow list for overlay_reset --- VERSION | 2 +- modules/config.py | 19 ++++++++++++++++--- modules/overlays.py | 31 +++++++++++++++++++------------ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/VERSION b/VERSION index d1bf427d..d43104df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.2-develop4 +1.18.2-develop5 diff --git a/modules/config.py b/modules/config.py index 374a8adc..c506bcd4 100644 --- a/modules/config.py +++ b/modules/config.py @@ -816,10 +816,23 @@ class ConfigFile: params["reapply_overlays"] = True if "reset_overlays" in file or "reset_overlay" in file: attr = f"reset_overlay{'s' if 'reset_overlays' in file else ''}" - if file[attr] and file[attr] in reset_overlay_options: - params["reset_overlays"] = file[attr] + if file[attr] and not isinstance(file[attr], list): + test_list = [file[attr]] else: - final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: " + test_list = file[attr] + final_list = [] + for test_item in test_list: + if test_item and test_item in reset_overlay_options: + final_list.append(test_item) + else: + final_text = f"Config Error: reset_overlays attribute {test_item} invalid. Options: " + for option, description in reset_overlay_options.items(): + final_text = f"{final_text}\n {option} ({description})" + logger.error(final_text) + if final_list: + params["reset_overlays"] = final_list + else: + final_text = f"Config Error: No proper reset_overlays option found. {file[attr]}. Options: " for option, description in reset_overlay_options.items(): final_text = f"{final_text}\n {option} ({description})" logger.error(final_text) diff --git a/modules/overlays.py b/modules/overlays.py index a31c9230..4b864a55 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -159,18 +159,25 @@ class Overlays: has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png") elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")): has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg") - if self.library.reset_overlays == "plex" or (has_original is None and self.library.reset_overlays is None): - temp_poster = next((p for p in item.posters() if p.provider == "local"), None) - if temp_poster: - new_backup = f"{self.library.url}{temp_poster.key}&X-Plex-Token={self.library.token}" - else: - logger.trace("Plex Error: Plex Poster Download Failed") - if self.library.reset_overlays == "tmdb" or (has_original is None and new_backup is None and self.library.reset_overlays is None): - try: - new_backup = self.find_poster_url(item) - except Failed as e: - logger.trace(e) - if not new_backup and self.library.reset_overlays is not None: + if self.library.reset_overlays: + reset_list = self.library.reset_overlays + elif has_original is None and not self.library.reset_overlays: + reset_list = ["plex", "tmdb"] + else: + reset_list = [] + for reset in reset_list: + if reset == "plex": + temp_poster = next((p for p in item.posters() if p.provider == "local"), None) + if temp_poster: + new_backup = f"{self.library.url}{temp_poster.key}&X-Plex-Token={self.library.token}" + else: + logger.trace("Plex Error: Plex Poster Download Failed") + if reset == "tmdb": + try: + new_backup = self.find_poster_url(item) + except Failed as e: + logger.trace(e) + if not new_backup and not self.library.reset_overlays: logger.error("Overlay Error: Reset Failed") else: new_backup = item.posterUrl