diff --git a/VERSION b/VERSION index 456894a9..e91b97eb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5-develop95 +1.16.5-develop96 diff --git a/docs/metadata/overlay.md b/docs/metadata/overlay.md index 040ebeda..63fb6af2 100644 --- a/docs/metadata/overlay.md +++ b/docs/metadata/overlay.md @@ -106,7 +106,9 @@ You can control the font, font size and font color using the `font`, `font_size` The `x_coordinate` and `y_coordinate` overlay attributes are required when using Text Overlays. -You can add an items rating to the image by using `text(audience_rating)`, `text(critic_rating)`, or `text(user_rating)` +You can add an items rating number (`8.7`) to the image by using `text(audience_rating)`, `text(critic_rating)`, or `text(user_rating)` + +You can add an items rating percentage (`87%`) to the image by using `text(audience_rating%)`, `text(critic_rating%)`, or `text(user_rating%)` Default font `Salma.otf` provided by [Alifinart Studio](https://www.behance.net/alifinart) diff --git a/modules/overlays.py b/modules/overlays.py index 9025c21d..fb0e728d 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -179,8 +179,10 @@ class Overlays: for over_name in text_names: overlay = properties[over_name] text = over_name[5:-1] - if text in ["audience_rating", "critic_rating", "user_rating"]: - rating_type = text + if text in [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "%"]]: + per = text[:-1] == "%" + rating_type = text[:-1] if per else text + actual = plex.attribute_translation[rating_type] if not hasattr(item, actual) or getattr(item, actual) is None: logger.error(f"Overlay Error: No {rating_type} found") @@ -188,6 +190,8 @@ class Overlays: text = getattr(item, actual) if self.config.Cache: self.config.Cache.update_overlay_ratings(item.ratingKey, rating_type, text) + if per: + text = f"{int(text * 10)}%" drawing.text(overlay.get_coordinates(image_width, image_height, text=str(text)), str(text), font=overlay.font, fill=overlay.font_color) temp = os.path.join(self.library.overlay_folder, f"temp.png") new_poster.save(temp, "PNG")