[96] percentage ratings

pull/877/head
meisnate12 3 years ago
parent 2b2b4e9a1f
commit 039a3d8254

@ -1 +1 @@
1.16.5-develop95 1.16.5-develop96

@ -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. 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) Default font `Salma.otf` provided by [Alifinart Studio](https://www.behance.net/alifinart)

@ -179,8 +179,10 @@ class Overlays:
for over_name in text_names: for over_name in text_names:
overlay = properties[over_name] overlay = properties[over_name]
text = over_name[5:-1] text = over_name[5:-1]
if text in ["audience_rating", "critic_rating", "user_rating"]: if text in [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "%"]]:
rating_type = text per = text[:-1] == "%"
rating_type = text[:-1] if per else text
actual = plex.attribute_translation[rating_type] actual = plex.attribute_translation[rating_type]
if not hasattr(item, actual) or getattr(item, actual) is None: if not hasattr(item, actual) or getattr(item, actual) is None:
logger.error(f"Overlay Error: No {rating_type} found") logger.error(f"Overlay Error: No {rating_type} found")
@ -188,6 +190,8 @@ class Overlays:
text = getattr(item, actual) text = getattr(item, actual)
if self.config.Cache: if self.config.Cache:
self.config.Cache.update_overlay_ratings(item.ratingKey, rating_type, text) 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) 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") temp = os.path.join(self.library.overlay_folder, f"temp.png")
new_poster.save(temp, "PNG") new_poster.save(temp, "PNG")

Loading…
Cancel
Save