From 9111f77c7ff5c94df94c0f317bafde7dac181ee9 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 19 Jul 2022 16:33:57 -0400 Subject: [PATCH] [42] add reset_overlays option --- VERSION | 2 +- docs/config/libraries.md | 30 ++++++++++++++++++++++++++++-- modules/builder.py | 5 ++--- modules/config.py | 11 +++++++++++ modules/library.py | 1 + modules/meta.py | 2 +- modules/overlays.py | 11 ++++++++--- 7 files changed, 52 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 5f921a59..b0fec8d2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.1-develop41 +1.17.1-develop42 diff --git a/docs/config/libraries.md b/docs/config/libraries.md index 355f34e1..4e7aef55 100644 --- a/docs/config/libraries.md +++ b/docs/config/libraries.md @@ -154,7 +154,7 @@ libraries: #### Remove Overlays -You can remove overlays from a library by adding `remove_overlays: true` to `overlay_path`. +You can remove overlays from a library by adding `remove_overlays: true` to `overlay_path`. This will remove all overlays when run and not generate new ones. ```yaml libraries: @@ -166,7 +166,33 @@ libraries: - file: config/Overlays.yml ``` -* This will remove all overlays when run and not generate new ones. +#### Reapply Overlays + +You can reapply overlays from a library by adding `reapply_overlays: true` to `overlay_path`. This will reapply overlays to every item in your library. + +```yaml +libraries: + TV Shows: + metadata_path: + - file: config/TV Shows.yml + overlay_path: + - reapply_overlays: true + - file: config/Overlays.yml +``` + +#### Reset Overlays + +You can reset overlays from a library by adding `reset_overlays` to `overlay_path` and setting it to either `tmdb` or `plex` depending on where you want to source the images from. This will use the reset image when overlaying items in your library. + +```yaml +libraries: + TV Shows: + metadata_path: + - file: config/TV Shows.yml + overlay_path: + - reset_overlays: plex + - file: config/Overlays.yml +``` ### Report Path diff --git a/modules/builder.py b/modules/builder.py index 0cb10557..c1678d7b 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -42,7 +42,7 @@ ignored_details = [ "smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test", "suppress_overlays", "delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level", "overlay", "validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection", - "allowed_library_types", "delete_playlist" + "allowed_library_types", "delete_playlist", "ignore_blank_results" ] details = [ "ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme", @@ -157,8 +157,7 @@ custom_sort_builders = [ episode_parts_only = ["plex_pilots"] overlay_only = ["overlay", "suppress_overlays"] overlay_attributes = [ - "filters", "limit", "show_missing", "save_report", "missing_only_released", "minimum_items", "cache_builders", - "tmdb_region", "default_percent", "ignore_blank_results" + "filters", "limit", "show_missing", "save_report", "missing_only_released", "minimum_items", "cache_builders", "tmdb_region", "default_percent" ] + all_builders + overlay_only parts_collection_valid = [ "filters", "plex_all", "plex_search", "trakt_list", "trakt_list_details", "collection_filtering", "collection_mode", "label", "visible_library", "limit", diff --git a/modules/config.py b/modules/config.py index 1d427a21..5492e120 100644 --- a/modules/config.py +++ b/modules/config.py @@ -55,6 +55,7 @@ mass_rating_options = { "anidb_rating": "Use AniDB Rating", "anidb_average": "Use AniDB Average" } +reset_overlay_options = {"tmdb": "Reset to TMDb poster", "plex": "Reset to Plex Poster"} class ConfigFile: def __init__(self, default_dir, attrs): @@ -783,6 +784,7 @@ class ConfigFile: params["overlay_path"] = [] params["remove_overlays"] = False params["reapply_overlays"] = False + params["reset_overlays"] = None if lib and "overlay_path" in lib: try: if not lib["overlay_path"]: @@ -799,6 +801,15 @@ class ConfigFile: if ("reapply_overlays" in file and file["reapply_overlays"] is True) \ or ("reapply_overlay" in file and file["reapply_overlay"] is True): 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] + else: + final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: " + for option, description in reset_overlay_options.items(): + final_text = f"{final_text}\n {option} ({description})" + logger.error(final_text) if "schedule" in file and file["schedule"]: logger.debug(f"Value: {file['schedule']}") err = None diff --git a/modules/library.py b/modules/library.py index 048158d0..c12dbdc7 100644 --- a/modules/library.py +++ b/modules/library.py @@ -93,6 +93,7 @@ class Library(ABC): self.remove_title_parentheses = params["remove_title_parentheses"] self.remove_overlays = params["remove_overlays"] self.reapply_overlays = params["reapply_overlays"] + self.reset_overlays = params["reset_overlays"] self.mass_collection_mode = params["mass_collection_mode"] self.metadata_backup = params["metadata_backup"] self.genre_mapper = params["genre_mapper"] diff --git a/modules/meta.py b/modules/meta.py index 86e4fa90..0cc98cba 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -898,7 +898,7 @@ class MetadataFile(DataFile): item = self.library.search_item(alt_title) if item is None: - logger.error(f"Skipping {mapping_name}: Item {mapping_name} not found") + logger.error(f"Skipping {mapping_name}: Item {title} not found") continue if not isinstance(item, list): item = [item] diff --git a/modules/overlays.py b/modules/overlays.py index 54f09951..63a9cd9e 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -153,14 +153,19 @@ class Overlays: if image_compare and str(poster.compare) != str(image_compare): changed_image = True elif has_overlay: - if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")): + if self.library.reset_overlays is not None: + if self.library.reset_overlays == "tmdb": + new_backup = self.find_poster_url(item) + else: + posters = item.posters() + if posters: + new_backup = posters[0] + elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")): 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") else: new_backup = self.find_poster_url(item) - if new_backup is None: - new_backup = item.posterUrl else: new_backup = item.posterUrl if new_backup: