[140] optimize overlay backdrops

pull/1345/head
meisnate12 2 years ago
parent 6be9e9fbaa
commit d3accfbb77

@ -1 +1 @@
1.18.3-develop139 1.18.3-develop140

@ -74,12 +74,8 @@ class Overlay:
self.keys = [] self.keys = []
self.updated = False self.updated = False
self.image = None self.image = None
self.landscape = None self.backdrop_box = None
self.landscape_box = None self.backdrop_text = None
self.portrait = None
self.portrait_box = None
self.square = None
self.square_box = None
self.group = None self.group = None
self.queue = None self.queue = None
self.queue_name = None self.queue_name = None
@ -285,13 +281,10 @@ class Overlay:
except ValueError: except ValueError:
raise Failed("Overlay Error: originally_available date format not valid") raise Failed("Overlay Error: originally_available date format not valid")
box = self.image.size if self.image else None 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.backdrop_box = box
self.landscape, self.landscape_box = self.get_backdrop(landscape_dim, box=box, text=self.name[5:-1]) self.backdrop_text = self.name[5:-1]
self.square, self.square_box = self.get_backdrop(square_dim, box=box, text=self.name[5:-1])
elif self.name.startswith("backdrop"): elif self.name.startswith("backdrop"):
self.portrait, self.portrait_box = self.get_backdrop(portrait_dim, box=self.back_box) self.backdrop_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)
else: else:
if not self.path: if not self.path:
clean_name, _ = util.validate_filename(self.name) clean_name, _ = util.validate_filename(self.name)
@ -306,9 +299,7 @@ class Overlay:
try: try:
self.image = Image.open(self.path).convert("RGBA") self.image = Image.open(self.path).convert("RGBA")
if self.has_coordinates(): if self.has_coordinates():
self.portrait, self.portrait_box = self.get_backdrop(portrait_dim, box=self.image.size) self.backdrop_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)
if self.config.Cache: 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) self.config.Cache.update_image_map(self.mapping_name, f"{self.library.image_table_name}_overlays", self.mapping_name, overlay_size)
except OSError: except OSError:
@ -438,8 +429,9 @@ class Overlay:
def get_canvas(self, item): def get_canvas(self, item):
if isinstance(item, Episode): if isinstance(item, Episode):
return self.landscape, self.landscape_box canvas_size = landscape_dim
elif isinstance(item, Album): elif isinstance(item, Album):
return self.square, self.square_box canvas_size = square_dim
else: 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)

@ -309,7 +309,7 @@ class Overlays:
else: else:
if current_overlay.has_coordinates(): if current_overlay.has_coordinates():
overlay_image, overlay_box = current_overlay.get_canvas(item) 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(overlay_image, (0, 0), overlay_image)
new_poster.paste(current_overlay.image, overlay_box, current_overlay.image) new_poster.paste(current_overlay.image, overlay_box, current_overlay.image)
else: else:

@ -827,8 +827,8 @@ class Plex(Library):
self.query_data(item.addLabel if add else item.removeLabel, collection) self.query_data(item.addLabel if add else item.removeLabel, collection)
else: else:
locked = True locked = True
if self.agent in ["tv.plex.agents.movie", "tv.plex.agents.series"]:
item = self.reload(item) item = self.reload(item)
if self.agent in ["tv.plex.agents.movie", "tv.plex.agents.series"]:
field = next((f for f in item.fields if f.name == "collection"), None) field = next((f for f in item.fields if f.name == "collection"), None)
locked = field is not None locked = field is not None
self.query_collection(item, collection, locked=locked, add=add) self.query_collection(item, collection, locked=locked, add=add)

Loading…
Cancel
Save