From d3accfbb7751fb38955ddf495eadce3a6f2787e5 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 16 Mar 2023 14:44:17 -0400 Subject: [PATCH] [140] optimize overlay backdrops --- VERSION | 2 +- modules/overlay.py | 28 ++++++++++------------------ modules/overlays.py | 2 +- modules/plex.py | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/VERSION b/VERSION index 847db4cc..6938fd5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop139 +1.18.3-develop140 diff --git a/modules/overlay.py b/modules/overlay.py index b919559f..a1930cfb 100644 --- a/modules/overlay.py +++ b/modules/overlay.py @@ -74,12 +74,8 @@ class Overlay: self.keys = [] self.updated = False self.image = None - self.landscape = None - self.landscape_box = None - self.portrait = None - self.portrait_box = None - self.square = None - self.square_box = None + self.backdrop_box = None + self.backdrop_text = None self.group = None self.queue = None self.queue_name = None @@ -285,13 +281,10 @@ class Overlay: except ValueError: raise Failed("Overlay Error: originally_available date format not valid") box = self.image.size if self.image else None - self.portrait, self.portrait_box = self.get_backdrop(portrait_dim, box=box, text=self.name[5:-1]) - self.landscape, self.landscape_box = self.get_backdrop(landscape_dim, box=box, text=self.name[5:-1]) - self.square, self.square_box = self.get_backdrop(square_dim, box=box, text=self.name[5:-1]) + self.backdrop_box = box + self.backdrop_text = self.name[5:-1] elif self.name.startswith("backdrop"): - self.portrait, self.portrait_box = self.get_backdrop(portrait_dim, box=self.back_box) - self.landscape, self.landscape_box = self.get_backdrop(landscape_dim, box=self.back_box) - self.square, self.square_box = self.get_backdrop(square_dim, box=self.back_box) + self.backdrop_box = self.back_box else: if not self.path: clean_name, _ = util.validate_filename(self.name) @@ -306,9 +299,7 @@ class Overlay: try: self.image = Image.open(self.path).convert("RGBA") if self.has_coordinates(): - self.portrait, self.portrait_box = self.get_backdrop(portrait_dim, box=self.image.size) - self.landscape, self.landscape_box = self.get_backdrop(landscape_dim, box=self.image.size) - self.square, self.square_box = self.get_backdrop(square_dim, box=self.image.size) + self.backdrop_box = self.image.size if self.config.Cache: self.config.Cache.update_image_map(self.mapping_name, f"{self.library.image_table_name}_overlays", self.mapping_name, overlay_size) except OSError: @@ -438,8 +429,9 @@ class Overlay: def get_canvas(self, item): if isinstance(item, Episode): - return self.landscape, self.landscape_box + canvas_size = landscape_dim elif isinstance(item, Album): - return self.square, self.square_box + canvas_size = square_dim else: - return self.portrait, self.portrait_box + canvas_size = portrait_dim + return self.get_backdrop(canvas_size, box=self.backdrop_box, text=self.backdrop_text) diff --git a/modules/overlays.py b/modules/overlays.py index d4050492..3696791d 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -309,7 +309,7 @@ class Overlays: else: if current_overlay.has_coordinates(): overlay_image, overlay_box = current_overlay.get_canvas(item) - if current_overlay.portrait is not None: + if current_overlay.backdrop_box is not None: new_poster.paste(overlay_image, (0, 0), overlay_image) new_poster.paste(current_overlay.image, overlay_box, current_overlay.image) else: diff --git a/modules/plex.py b/modules/plex.py index f8465cc9..0e215241 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -827,8 +827,8 @@ class Plex(Library): self.query_data(item.addLabel if add else item.removeLabel, collection) else: locked = True + item = self.reload(item) if self.agent in ["tv.plex.agents.movie", "tv.plex.agents.series"]: - item = self.reload(item) field = next((f for f in item.fields if f.name == "collection"), None) locked = field is not None self.query_collection(item, collection, locked=locked, add=add)