From d122a6af66d158c12158a1768b2e156ef2f70b60 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 8 Aug 2023 14:15:03 -0400 Subject: [PATCH] [80] fix rating overlays --- VERSION | 2 +- defaults/overlays/ratings.yml | 4 ++- docs/defaults/overlays/ratings.md | 52 +++++++++++++++---------------- docs/metadata/overlay.md | 6 ++-- modules/overlay.py | 6 ++-- modules/overlays.py | 8 +++-- requirements.txt | 2 +- 7 files changed, 42 insertions(+), 38 deletions(-) diff --git a/VERSION b/VERSION index ba2a4922..92d799e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.19.0-develop79 +1.19.0-develop80 diff --git a/defaults/overlays/ratings.yml b/defaults/overlays/ratings.yml index 30feabb6..0f0e21d0 100644 --- a/defaults/overlays/ratings.yml +++ b/defaults/overlays/ratings.yml @@ -106,6 +106,8 @@ templates: value: "%" - rating<>_image: [metacritic, mdb] value: "0" + - rating<>_image: [letterboxd] + value: "/" image_extra: default: "" conditions: @@ -449,7 +451,7 @@ templates: run_definition: <> ignore_blank_results: true overlay: - name: text(<>>>_rating<>_style>>) + name: text(<<<>>>_rating<>_style>>>>) file: <>_file>> url: <>_url>> git: <>_git>> diff --git a/docs/defaults/overlays/ratings.md b/docs/defaults/overlays/ratings.md index bb6d33f2..05f6600c 100644 --- a/docs/defaults/overlays/ratings.md +++ b/docs/defaults/overlays/ratings.md @@ -84,32 +84,32 @@ All [Shared Overlay Variables](../overlay_variables) can be appended by `rating1 | `back_radius` | `30` | | `back_height` | `105` | -| Variable | Description & Values | -|:-----------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `rating1` | **Description:** Choose the rating to display in rating1.
**Values:** `critic`, `audience`, or `user` | -| `rating1_image` | **Description:** Choose the rating image to display in rating1.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | -| `rating1_style` | **Description:** Choose the rating number style for rating1.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0"#"8.7, 9
Hundred Scale"%"87, 90
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| -| `rating2` | **Description:** Choose the rating to display in rating2.
**Values:** `critic`, `audience`, or `user` | -| `rating2_image` | **Description:** Choose the rating image to display in rating2.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | -| `rating2_style` | **Description:** Choose the rating number style for rating2.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0"#"8.7, 9
Hundred Scale"%"87, 90
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| -| `rating3` | **Description:** Choose the rating to display in rating3.
**Values:** `critic`, `audience`, or `user` | -| `rating3_image` | **Description:** Choose the rating image to display in rating3.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | -| `rating3_style` | **Description:** Choose the rating number style for rating3.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0"#"8.7, 9
Hundred Scale"%"87, 90
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| -| `horizontal_position` | **Description:** Choose the horizontal position for the rating group.
**Default:** `left`
**Values:** `left`, `right`, or `center` | -| `vertical_position` | **Description:** Choose the vertical position for the rating group.
**Default:** `center`
**Values:** `top`, `bottom`, or `center` | -| `rating_alignment` | **Description:** Choose the display alignment for the rating group.
**Default:** `vertical`
**Values:** `horizontal`, or `vertical` | -| `minimum_rating` | **Description:** Minimum Rating to display
**Default:** 0.0
**Values:** Any Number | -| `fresh_rating` | **Description:** Determines when ratings are considered Fresh
**Default:** 6.0
**Values:** Any Number | -| `maximum_rating` | **Description:** Maximum Rating to display
**Default:** 10.0
**Values:** Any Number | -| `font`1 | **Description:** Choose the font for the Overlay.
**Default:** `fonts/Inter-Bold.ttf`
**Values:** Path to font file | -| `font_style`1 | **Description:** Font style for Variable Fonts.
**Values:** Variable Font Style | -| `font_size`1 | **Description:** Choose the font size for the Overlay.
**Default:** `63`
**Values:** Any Number greater then 0 | -| `font_color`1 | **Description:** Choose the font color for the Overlay.
**Default:** `#FFFFFF`
**Values:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA` | -| `stroke_width`1 | **Description:** Font Stroke Width for the Text Overlay.
**Values:** Any Number greater then 0 | -| `stroke_color`1 | **Description:** Font Stroke Color for the Text Overlay.
**Values:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA` | -| `addon_offset`1 | **Description:** Text Addon Image Offset from the text.
**Default:** `15`
**Values:** Any Number greater then 0 | -| `addon_position`1 | **Description:** Text Addon Image Alignment in relation to the text.
**Default:** `left`
**Values:** `left`, `right`, `top`, `bottom` | -| `builder_level` | **Description:** Choose the Overlay Level.
**Values:** `episode` | +| Variable | Description & Values | +|:-----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `rating1` | **Description:** Choose the rating to display in rating1.
**Values:** `critic`, `audience`, or `user` | +| `rating1_image` | **Description:** Choose the rating image to display in rating1.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | +| `rating1_style` | **Description:** Choose the rating number style for rating1.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0 "#"8.7, 9
Hundred Scale"0"87, 90
Hundred Scale with % "%"87%, 90%
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| +| `rating2` | **Description:** Choose the rating to display in rating2.
**Values:** `critic`, `audience`, or `user` | +| `rating2_image` | **Description:** Choose the rating image to display in rating2.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | +| `rating2_style` | **Description:** Choose the rating number style for rating2.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0 "#"8.7, 9
Hundred Scale"0"87, 90
Hundred Scale with % "%"87%, 90%
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| +| `rating3` | **Description:** Choose the rating to display in rating3.
**Values:** `critic`, `audience`, or `user` | +| `rating3_image` | **Description:** Choose the rating image to display in rating3.
**Values:** `anidb`, `imdb`, `letterboxd`, `tmdb`, `metacritic`, `rt_popcorn`, `rt_tomato`, `trakt`, `mal`, `mdb`, or `star` | +| `rating3_style` | **Description:** Choose the rating number style for rating3.
**Values:**
Ten Scale""8.7, 9.0
Ten Scale removing .0 "#"8.7, 9
Hundred Scale"0"87, 90
Hundred Scale with % "%"87%, 90%
Five Scale"/"8.6 rating in plex will show as 4.3 on the overlay
| +| `horizontal_position` | **Description:** Choose the horizontal position for the rating group.
**Default:** `left`
**Values:** `left`, `right`, or `center` | +| `vertical_position` | **Description:** Choose the vertical position for the rating group.
**Default:** `center`
**Values:** `top`, `bottom`, or `center` | +| `rating_alignment` | **Description:** Choose the display alignment for the rating group.
**Default:** `vertical`
**Values:** `horizontal`, or `vertical` | +| `minimum_rating` | **Description:** Minimum Rating to display
**Default:** 0.0
**Values:** Any Number | +| `fresh_rating` | **Description:** Determines when ratings are considered Fresh
**Default:** 6.0
**Values:** Any Number | +| `maximum_rating` | **Description:** Maximum Rating to display
**Default:** 10.0
**Values:** Any Number | +| `font`1 | **Description:** Choose the font for the Overlay.
**Default:** `fonts/Inter-Bold.ttf`
**Values:** Path to font file | +| `font_style`1 | **Description:** Font style for Variable Fonts.
**Values:** Variable Font Style | +| `font_size`1 | **Description:** Choose the font size for the Overlay.
**Default:** `63`
**Values:** Any Number greater then 0 | +| `font_color`1 | **Description:** Choose the font color for the Overlay.
**Default:** `#FFFFFF`
**Values:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA` | +| `stroke_width`1 | **Description:** Font Stroke Width for the Text Overlay.
**Values:** Any Number greater then 0 | +| `stroke_color`1 | **Description:** Font Stroke Color for the Text Overlay.
**Values:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA` | +| `addon_offset`1 | **Description:** Text Addon Image Offset from the text.
**Default:** `15`
**Values:** Any Number greater then 0 | +| `addon_position`1 | **Description:** Text Addon Image Alignment in relation to the text.
**Default:** `left`
**Values:** `left`, `right`, `top`, `bottom` | +| `builder_level` | **Description:** Choose the Overlay Level.
**Values:** `episode` | 1. These Variables can be appended by `rating1_`, `rating2_`, or `rating3_` to change that attribute on each rating individually. diff --git a/docs/metadata/overlay.md b/docs/metadata/overlay.md index 9726dd44..3883206d 100644 --- a/docs/metadata/overlay.md +++ b/docs/metadata/overlay.md @@ -201,9 +201,9 @@ There are multiple Special Text Variables that can be used when formatting the t | Special Text Variables & Mods | Movies | Shows | Seasons | Episodes | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:| -| `<>`: audience rating (`8.7`, `9.0`)
`<>`: audience rating out of 100 (`87`, `90`)
`<>`: audience rating removing `.0` as needed (`8.7`, `9`)
`<>`: audience rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ❌ | ✅ | -| `<>`: critic rating (`8.7`, `9.0`)
`<>`: critic rating out of 100 (`87`, `90`)
`<>`: critic rating removing `.0` as needed (`8.7`, `9`)
`<>`: critic rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ❌ | ✅ | -| `<>`: user rating (`8.7`, `9.0`)
`<>`: user rating out of 100 (`87`, `90`)
`<>`: user rating removing `.0` as needed (`8.7`, `9`)
`<>`: user rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ✅ | ✅ | +| `<>`: audience rating (`8.7`, `9.0`)
`<>`: audience rating out of 100 (`87`, `90`)
`<>`: audience rating out of 100 ending with `%` (`87%`, `90%`)
`<>`: audience rating removing `.0` as needed (`8.7`, `9`)
`<>`: audience rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ❌ | ✅ | +| `<>`: critic rating (`8.7`, `9.0`)
`<>`: critic rating out of 100 (`87`, `90`)
`<>`: critic rating out of 100 ending with `%` (`87%`, `90%`)
`<>`: critic rating removing `.0` as needed (`8.7`, `9`)
`<>`: critic rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ❌ | ✅ | +| `<>`: user rating (`8.7`, `9.0`)
`<>`: user rating out of 100 (`87`, `90`)
`<>`: user rating out of 100 ending with `%` (`87%`, `90%`)
`<>`: user rating removing `.0` as needed (`8.7`, `9`)
`<>`: user rating on a 5 point scale (`8.6` shows as `4.3`) | ✅ | ✅ | ✅ | ✅ | | `<>`: Title of the Item<br>`<<titleU>>`: Uppercase Title of the Item<br>`<<titleL>>`Lowercase Title of the Item<br>`<<titleP>>`Proper Title of the Item | ✅ | ✅ | ✅ | ✅ | | `<<show_title>>`: Title of the Item's Show<br>`<<show_itleU>>`: Uppercase Title of the Item's Show<br>`<<show_titleL>>`Lowercase Title of the Item's Show<br>`<<show_titleP>>`Proper Title of the Item's Show | ❌ | ❌ | ✅ | ✅ | | `<<season_title>>`: Title of the Item's Season<br>`<<season_titleU>>`: Uppercase Title of the Item's Season<br>`<<season_titleL>>`Lowercase title of the Item's Season<br>`<<season_titleP>>`Proper title of the Item's Season | ❌ | ❌ | ❌ | ✅ | diff --git a/modules/overlay.py b/modules/overlay.py index 1c2a7243..53acabc6 100644 --- a/modules/overlay.py +++ b/modules/overlay.py @@ -34,9 +34,9 @@ var_mods = { "show_title": ["", "U", "L", "P"], "season_title": ["", "U", "L", "P"], "bitrate": ["", "H", "L"], - "user_rating": ["", "%", "#", "/"], - "critic_rating": ["", "%", "#", "/"], - "audience_rating": ["", "%", "#", "/"], + "user_rating": ["", "%", "#", "/", "0"], + "critic_rating": ["", "%", "#", "/", "0"], + "audience_rating": ["", "%", "#", "/", "0"], "originally_available": ["", "["], "runtime": ["", "H", "M"], "season_number": ["", "W", "WU", "WL", "0", "00"], diff --git a/modules/overlays.py b/modules/overlays.py index 881e6e76..b3826aa9 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -259,9 +259,13 @@ class Overlays: else: final_value = int(actual_value / 60000) elif mod == "%": - final_value = int(actual_value * 10) + final_value = f"{int(actual_value * 10)}%" elif mod == "#": final_value = str(actual_value)[:-2] if str(actual_value).endswith(".0") else actual_value + elif mod == "/": + final_value = f"{float(actual_value) / 2:.1f}" + elif mod == "0" and format_var in ["audience_rating", "critic_rating", "user_rating"]: + final_value = int(actual_value * 10) elif mod == "W": final_value = num2words(int(actual_value)) elif mod == "WU": @@ -272,8 +276,6 @@ class Overlays: final_value = f"{int(actual_value):02}" elif mod == "00": final_value = f"{int(actual_value):03}" - elif mod == "/": - final_value = f"{float(actual_value) / 2:.1f}" elif mod == "U": final_value = str(actual_value).upper() elif mod == "L": diff --git a/requirements.txt b/requirements.txt index 852ca25f..d48f0f47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ lxml==4.9.3 num2words==0.5.12 pathvalidate==3.1.0 pillow==10.0.0 -PlexAPI==4.14.0 +PlexAPI==4.15.0 psutil==5.9.5 python-dotenv==1.0.0 requests==2.31.0