added url overlays

pull/575/head
meisnate12 3 years ago
parent de8225aeeb
commit 30df98ed13

@ -1 +1 @@
1.14.1
1.14.1-develop1522

@ -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":
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

@ -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

Loading…
Cancel
Save