mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[101] fix positional overlays
This commit is contained in:
parent
de737d9aca
commit
6754e798b5
6 changed files with 25 additions and 26 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.16.5-develop100
|
||||
1.16.5-develop101
|
||||
|
|
|
@ -221,7 +221,7 @@ class CollectionBuilder:
|
|||
logger.debug("")
|
||||
logger.debug("Validating Method: 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']]}")
|
||||
found_type = False
|
||||
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_music: self.collection_level = "artist"
|
||||
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("Validating Method: collection_level")
|
||||
if self.library.is_movie:
|
||||
raise Failed(f"{self.Type} Error: collection_level attribute only works for show and music libraries")
|
||||
elif self.data[methods["collection_level"]] is None:
|
||||
level = self.data[methods["collection_level"]]
|
||||
if level is None:
|
||||
raise Failed(f"{self.Type} Error: collection_level attribute is blank")
|
||||
else:
|
||||
logger.debug(f"Value: {self.data[methods['collection_level']]}")
|
||||
if (self.library.is_show and self.data[methods["collection_level"]].lower() in plex.collection_level_show_options) or \
|
||||
(self.library.is_music and self.data[methods["collection_level"]].lower() in plex.collection_level_music_options):
|
||||
self.collection_level = self.data[methods["collection_level"]].lower()
|
||||
else:
|
||||
logger.debug(f"Value: {level}")
|
||||
level = level.lower()
|
||||
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.collection_level = level
|
||||
elif (self.library.is_show and level != "show") or (self.library.is_music and level != "artist"):
|
||||
if self.library.is_show:
|
||||
options = "\n\tseason (Collection at the Season Level)\n\tepisode (Collection at the Episode Level)"
|
||||
else:
|
||||
|
|
|
@ -18,7 +18,6 @@ class Library(ABC):
|
|||
self.Notifiarr = None
|
||||
self.collections = []
|
||||
self.metadatas = []
|
||||
self.overlays = []
|
||||
self.metadata_files = []
|
||||
self.overlay_files = []
|
||||
self.movie_map = {}
|
||||
|
@ -133,9 +132,7 @@ class Library(ABC):
|
|||
if not operations_only and not collection_only:
|
||||
for file_type, overlay_file, temp_vars, asset_directory in self.overlay_path:
|
||||
try:
|
||||
over_obj = 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)
|
||||
self.overlay_files.append(OverlayFile(self.config, self, file_type, overlay_file, temp_vars, asset_directory))
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
|
||||
|
|
|
@ -1174,7 +1174,7 @@ class OverlayFile(DataFile):
|
|||
logger.info("")
|
||||
logger.info(f"Loading Overlay {file_type}: {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.external_templates(data)
|
||||
if not self.overlays:
|
||||
|
|
|
@ -6,7 +6,7 @@ from modules.util import Failed, NotScheduled
|
|||
from plexapi.audio import Album
|
||||
from plexapi.exceptions import BadRequest
|
||||
from plexapi.video import Movie, Show, Season, Episode
|
||||
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
||||
from PIL import Image, ImageDraw, ImageFilter
|
||||
|
||||
logger = util.logger
|
||||
|
||||
|
@ -178,7 +178,7 @@ class Overlays:
|
|||
overlay = properties[over_name]
|
||||
text = over_name[5:-1]
|
||||
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
|
||||
|
||||
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):
|
||||
raise Failed(f"{error} between -50% and 50%")
|
||||
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
|
||||
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):
|
||||
raise Failed(f"{error} between -50% and 50%")
|
||||
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")
|
||||
|
||||
def get_and_save_image(image_url):
|
||||
|
@ -1019,11 +1023,11 @@ class Overlay:
|
|||
width, height = self.image.size
|
||||
|
||||
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"]:
|
||||
return image_value - over_value - value
|
||||
elif align == "center":
|
||||
return (image_value / 2) - (over_value / 2) + value
|
||||
return int(image_value / 2) - int(over_value / 2) + value
|
||||
else:
|
||||
return value
|
||||
|
||||
|
|
Loading…
Reference in a new issue