[101] fix positional overlays

pull/877/head
meisnate12 3 years ago
parent de737d9aca
commit 6754e798b5

@ -1 +1 @@
1.16.5-develop100 1.16.5-develop101

@ -221,7 +221,7 @@ class CollectionBuilder:
logger.debug("") logger.debug("")
logger.debug("Validating Method: allowed_library_types") logger.debug("Validating Method: allowed_library_types")
if not self.data[methods["allowed_library_types"]]: if not self.data[methods["allowed_library_types"]]:
raise Failed(f"{self.Type} Error: allowed_library_types attribute is blank") raise NotScheduled(f"Skipped because allowed_library_types has no library types")
logger.debug(f"Value: {data[methods['allowed_library_types']]}") logger.debug(f"Value: {data[methods['allowed_library_types']]}")
found_type = False found_type = False
for library_type in util.get_list(self.data[methods["allowed_library_types"]], lower=True): for library_type in util.get_list(self.data[methods["allowed_library_types"]], lower=True):
@ -446,19 +446,17 @@ class CollectionBuilder:
elif self.library.is_show: self.collection_level = "show" elif self.library.is_show: self.collection_level = "show"
elif self.library.is_music: self.collection_level = "artist" elif self.library.is_music: self.collection_level = "artist"
else: self.collection_level = "movie" else: self.collection_level = "movie"
if "collection_level" in methods and not self.playlist: if "collection_level" in methods and not self.library.is_movie and not self.playlist:
logger.debug("") logger.debug("")
logger.debug("Validating Method: collection_level") logger.debug("Validating Method: collection_level")
if self.library.is_movie: level = self.data[methods["collection_level"]]
raise Failed(f"{self.Type} Error: collection_level attribute only works for show and music libraries") if level is None:
elif self.data[methods["collection_level"]] is None:
raise Failed(f"{self.Type} Error: collection_level attribute is blank") raise Failed(f"{self.Type} Error: collection_level attribute is blank")
else: logger.debug(f"Value: {level}")
logger.debug(f"Value: {self.data[methods['collection_level']]}") level = level.lower()
if (self.library.is_show and self.data[methods["collection_level"]].lower() in plex.collection_level_show_options) or \ if (self.library.is_show and level in plex.collection_level_show_options) or (self.library.is_music and level in plex.collection_level_music_options):
(self.library.is_music and self.data[methods["collection_level"]].lower() in plex.collection_level_music_options): self.collection_level = level
self.collection_level = self.data[methods["collection_level"]].lower() elif (self.library.is_show and level != "show") or (self.library.is_music and level != "artist"):
else:
if self.library.is_show: if self.library.is_show:
options = "\n\tseason (Collection at the Season Level)\n\tepisode (Collection at the Episode Level)" options = "\n\tseason (Collection at the Season Level)\n\tepisode (Collection at the Episode Level)"
else: else:

@ -18,7 +18,6 @@ class Library(ABC):
self.Notifiarr = None self.Notifiarr = None
self.collections = [] self.collections = []
self.metadatas = [] self.metadatas = []
self.overlays = []
self.metadata_files = [] self.metadata_files = []
self.overlay_files = [] self.overlay_files = []
self.movie_map = {} self.movie_map = {}
@ -133,9 +132,7 @@ class Library(ABC):
if not operations_only and not collection_only: if not operations_only and not collection_only:
for file_type, overlay_file, temp_vars, asset_directory in self.overlay_path: for file_type, overlay_file, temp_vars, asset_directory in self.overlay_path:
try: try:
over_obj = OverlayFile(self.config, self, file_type, overlay_file, temp_vars, asset_directory) self.overlay_files.append(OverlayFile(self.config, self, file_type, overlay_file, temp_vars, asset_directory))
self.overlays.extend([o.lower() for o in over_obj.overlays])
self.overlay_files.append(over_obj)
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)

@ -1174,7 +1174,7 @@ class OverlayFile(DataFile):
logger.info("") logger.info("")
logger.info(f"Loading Overlay {file_type}: {path}") logger.info(f"Loading Overlay {file_type}: {path}")
data = self.load_file(self.type, self.path) data = self.load_file(self.type, self.path)
self.overlays = get_dict("overlays", data, self.library.overlays) self.overlays = get_dict("overlays", data)
self.templates = get_dict("templates", data) self.templates = get_dict("templates", data)
self.external_templates(data) self.external_templates(data)
if not self.overlays: if not self.overlays:

@ -6,7 +6,7 @@ from modules.util import Failed, NotScheduled
from plexapi.audio import Album from plexapi.audio import Album
from plexapi.exceptions import BadRequest from plexapi.exceptions import BadRequest
from plexapi.video import Movie, Show, Season, Episode from plexapi.video import Movie, Show, Season, Episode
from PIL import Image, ImageDraw, ImageFilter, ImageFont from PIL import Image, ImageDraw, ImageFilter
logger = util.logger logger = util.logger
@ -178,7 +178,7 @@ class Overlays:
overlay = properties[over_name] overlay = properties[over_name]
text = over_name[5:-1] text = over_name[5:-1]
if text in [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "%"]]: if text in [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "%"]]:
per = text[:-1] == "%" per = text.endswith("%")
rating_type = text[:-1] if per else text rating_type = text[:-1] if per else text
actual = plex.attribute_translation[rating_type] actual = plex.attribute_translation[rating_type]

@ -884,6 +884,8 @@ class Overlay:
elif self.horizontal_align == "center" and per and (x_off > 50 or x_off < -50): elif self.horizontal_align == "center" and per and (x_off > 50 or x_off < -50):
raise Failed(f"{error} between -50% and 50%") raise Failed(f"{error} between -50% and 50%")
self.horizontal_offset = f"{x_off}%" if per else x_off self.horizontal_offset = f"{x_off}%" if per else x_off
if self.horizontal_offset is None and self.horizontal_align == "center":
self.horizontal_offset = 0
self.vertical_offset = None self.vertical_offset = None
if "vertical_offset" in self.data and self.data["vertical_offset"] is not None: if "vertical_offset" in self.data and self.data["vertical_offset"] is not None:
@ -903,8 +905,10 @@ class Overlay:
elif self.vertical_align == "center" and per and (y_off > 50 or y_off < -50): elif self.vertical_align == "center" and per and (y_off > 50 or y_off < -50):
raise Failed(f"{error} between -50% and 50%") raise Failed(f"{error} between -50% and 50%")
self.vertical_offset = f"{y_off}%" if per else y_off self.vertical_offset = f"{y_off}%" if per else y_off
if self.vertical_offset is None and self.vertical_align == "center":
self.vertical_offset = 0
if ("horizontal_offset" in self.data or "vertical_offset" in self.data) and (self.horizontal_offset is None or self.vertical_offset is None): if (self.horizontal_offset is not None or self.vertical_offset is not None) and (self.horizontal_offset is None or self.vertical_offset is None):
raise Failed(f"Overlay Error: overlay horizontal_offset and overlay vertical_offset must be used together") raise Failed(f"Overlay Error: overlay horizontal_offset and overlay vertical_offset must be used together")
def get_and_save_image(image_url): def get_and_save_image(image_url):
@ -1019,11 +1023,11 @@ class Overlay:
width, height = self.image.size width, height = self.image.size
def get_cord(value, image_value, over_value, align): def get_cord(value, image_value, over_value, align):
value = image_value * 0.01 * int(value[:-1]) if str(value).endswith("%") else value value = int(image_value * 0.01 * int(value[:-1])) if str(value).endswith("%") else value
if align in ["right", "bottom"]: if align in ["right", "bottom"]:
return image_value - over_value - value return image_value - over_value - value
elif align == "center": elif align == "center":
return (image_value / 2) - (over_value / 2) + value return int(image_value / 2) - int(over_value / 2) + value
else: else:
return value return value

Loading…
Cancel
Save