[15] fix special text overlays

pull/994/head
meisnate12 2 years ago
parent ce6ffbd4f2
commit 47d5e96ab6

@ -1 +1 @@
1.17.2-develop14
1.17.2-develop15

@ -171,7 +171,7 @@ overlays:
#### Special Text Variables
You can use the item's metadata to determine the text by adding Special Text Variables to you text Overlay.
You can use the item's metadata to determine the text by adding Special Text Variables to your text Overlay.
There are multiple Special Text Variables that can be used when formatting the text. The variables are defined like so `<<name>>` and some can have modifiers like so `<<name$>>` where `$` is the modifier. The available options are:
@ -235,6 +235,7 @@ overlays:
```
##### Common Special Text Uses
These are some commonly-used examples of Special Text overlays:
| Special Text | Example Output |
@ -246,7 +247,6 @@ These are some commonly-used examples of Special Text overlays:
| `name: text(Runtime: <<runtime>>m)` | Runtime: 90m |
| `name: text(Runtime: <<runtimeH>>h <<runtimeM>>m)` | Runtime: 1h 30m |
#### Text Addon Images
You can add an image to accompany the text by specifying the image location using `file`, `url`, `git`, or `repo`.

@ -8,7 +8,7 @@ logger = util.logger
portrait_dim = (1000, 1500)
landscape_dim = (1920, 1080)
old_special_text2 = [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "0", "%", "#"]]
old_special_text = [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "0", "%", "#"]]
float_vars = ["audience_rating", "critic_rating", "user_rating"]
int_vars = ["runtime", "season_number", "episode_number", "episode_count"]
date_vars = ["originally_available"]
@ -281,7 +281,7 @@ class Overlay:
self.font_color = ImageColor.getcolor(self.data["font_color"], "RGBA")
except ValueError:
raise Failed(f"Overlay Error: overlay font_color: {self.data['font_color']} invalid")
if text in old_special_text2:
if text in old_special_text:
text_mod = text[-1] if text[-1] in ["0", "%", "#"] else None
text = text if text_mod is None else text[:-1]
self.name = f"text(<<{text}#>>)" if text_mod == "#" else f"text(<<{text}%>>{'' if text_mod == '0' else '%'})"

@ -265,7 +265,7 @@ class Overlays:
for over_name in applied_names:
current_overlay = properties[over_name]
if current_overlay.name.startswith("text"):
if current_overlay.name == "text(special_text)":
if "<<" in current_overlay.name:
image_box = current_overlay.image.size if current_overlay.image else None
try:
overlay_image, addon_box = current_overlay.get_backdrop((canvas_width, canvas_height), box=image_box, text=get_text(current_overlay))

Loading…
Cancel
Save