From 30df98ed13fbd88e3d7fa50da01bc78f3aa507c9 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 5 Jan 2022 10:42:38 -0500 Subject: [PATCH] added url overlays --- VERSION | 2 +- modules/builder.py | 29 +++++++++++++++++++++++------ modules/library.py | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 30f101cb..cb74a392 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.14.1 \ No newline at end of file +1.14.1-develop1522 \ No newline at end of file diff --git a/modules/builder.py b/modules/builder.py index 795c4d61..805da213 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1,4 +1,4 @@ -import logging, os, re +import logging, os, re, time from datetime import datetime, timedelta from modules import anidb, anilist, flixpatrol, icheckmovies, imdb, letterboxd, mal, plex, radarr, sonarr, stevenlu, tautulli, tmdb, trakt, tvdb, util from modules.util import Failed, ImageData, NotScheduled @@ -809,13 +809,30 @@ class CollectionBuilder: self.item_details[method_name] = util.get_list(method_data, lower=True) self.item_details["apply_tags"] = method_mod[1:] if method_mod else "" elif method_name == "item_overlay": - overlay = os.path.join(self.config.default_dir, "overlays", method_data, "overlay.png") + if isinstance(method_data, dict): + if "name" not in method_data or "url" not in method_data or not method_data["name"] or not method_data["url"]: + raise Failed(f"{self.Type} Error: item_overlay must have both name and url attributes") + name = method_data["name"] + response = self.config.get(method_data["url"]) + if response.status_code >= 400: + raise Failed(f"{self.Type} Error: Overlay Image not found at: {method_data['url']}") + overlay_dir = os.path.join(self.config.default_dir, "overlays", name) + if not os.path.exists(overlay_dir) or not os.path.isdir(overlay_dir): + raise Failed(f"{self.Type} Error: Overlay Folder not found at: {overlay_dir}") + overlay = os.path.join(overlay_dir, "overlay.png") + with open(overlay, "wb") as handler: + handler.write(response.content) + while util.is_locked(overlay): + time.sleep(1) + else: + overlay = os.path.join(self.config.default_dir, "overlays", method_data, "overlay.png") + name = method_data if not os.path.exists(overlay): - raise Failed(f"{self.Type} Error: {method_data} overlay image not found at {overlay}") - if method_data in self.library.overlays: + raise Failed(f"{self.Type} Error: {name} overlay image not found at {overlay}") + if name in self.library.overlays: raise Failed("Each Overlay can only be used once per Library") - self.library.overlays.append(method_data) - self.item_details[method_name] = method_data + self.library.overlays.append(name) + self.item_details[method_name] = name elif method_name in item_bool_details: if self._parse(method_name, method_data, datatype="bool", default=False): self.item_details[method_name] = True diff --git a/modules/library.py b/modules/library.py index 5f6607cf..89d06af5 100644 --- a/modules/library.py +++ b/modules/library.py @@ -89,7 +89,7 @@ class Library(ABC): or self.tmdb_collections or self.radarr_add_all_existing or self.sonarr_add_all_existing self.library_operation = self.tmdb_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \ or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \ - or self.genre_collections or self.genre_mapper + or self.genre_collections or self.genre_mapper or self.show_unmanaged metadata = [] for file_type, metadata_file in self.metadata_path: if file_type == "Folder": @@ -158,7 +158,7 @@ class Library(ABC): if poster_uploaded or image is None or image != item.thumb or f"{overlay_name.lower()} overlay" not in item_labels: if not item.posterUrl: raise Failed(f"Overlay Error: No existing poster to Overlay for {item.title}") - response = requests.get(item.posterUrl) + response = self.config.get(item.posterUrl) if response.status_code >= 400: raise Failed(f"Overlay Error: Overlay Failed for {item.title}") og_image = response.content