[64] small fixes and new rating style

pull/949/head
meisnate12 2 years ago
parent 921a807392
commit 7e876b278f

@ -1 +1 @@
1.17.0-develop63 1.17.0-develop64

@ -156,6 +156,8 @@ You can add an items rating number removing `.0` as needed (`8.7`, `9`) to the i
You can add an items rating percentage (`87%`, `90%`) to the image by using `text(audience_rating%)`, `text(critic_rating%)`, or `text(user_rating%)` You can add an items rating percentage (`87%`, `90%`) to the image by using `text(audience_rating%)`, `text(critic_rating%)`, or `text(user_rating%)`
You can add an items rating out of 100 (`87`, `90`) to the image by using `text(audience_rating0)`, `text(critic_rating0)`, or `text(user_rating0)`
You can use the `mass_audience_rating_update` or `mass_critic_rating_update` [Library Operation](../config/operations) to update your plex ratings to various services like `tmdb`, `imdb`, `mdb`, `metacritic`, `letterboxd` and many more. You can use the `mass_audience_rating_update` or `mass_critic_rating_update` [Library Operation](../config/operations) to update your plex ratings to various services like `tmdb`, `imdb`, `mdb`, `metacritic`, `letterboxd` and many more.
PMM includes multiple fonts in the [`fonts` folder](https://github.com/meisnate12/Plex-Meta-Manager/tree/master/fonts) which can be called using `fonts/fontname.ttf` PMM includes multiple fonts in the [`fonts` folder](https://github.com/meisnate12/Plex-Meta-Manager/tree/master/fonts) which can be called using `fonts/fontname.ttf`

@ -260,7 +260,7 @@ class CollectionBuilder:
suppress = util.get_list(data[methods["suppress_overlays"]]) suppress = util.get_list(data[methods["suppress_overlays"]])
else: else:
logger.error(f"Overlay Error: suppress_overlays attribute is blank") logger.error(f"Overlay Error: suppress_overlays attribute is blank")
self.overlay = Overlay(config, library, overlay_data, suppress) self.overlay = Overlay(config, library, str(self.mapping_name), overlay_data, suppress)
self.sync_to_users = None self.sync_to_users = None
self.valid_users = [] self.valid_users = []

@ -200,7 +200,7 @@ class Operations:
if tmdb_item and attribute == "tmdb": if tmdb_item and attribute == "tmdb":
return tmdb_item.vote_average return tmdb_item.vote_average
elif imdb_id and attribute == "imdb": elif imdb_id and attribute == "imdb":
return self.config.imdb.get_rating(imdb_id) return self.config.IMDb.get_rating(imdb_id)
elif omdb_item and attribute == "omdb": elif omdb_item and attribute == "omdb":
return omdb_item.imdb_rating return omdb_item.imdb_rating
elif mdb_item and attribute == "mdb": elif mdb_item and attribute == "mdb":
@ -234,8 +234,8 @@ class Operations:
if self.library.mass_genre_update: if self.library.mass_genre_update:
if tmdb_item and self.library.mass_genre_update == "tmdb": if tmdb_item and self.library.mass_genre_update == "tmdb":
new_genres = tmdb_item.genres new_genres = tmdb_item.genres
elif imdb_id and self.library.mass_genre_update == "imdb" and imdb_id in self.config.imdb.genres: elif imdb_id and self.library.mass_genre_update == "imdb" and imdb_id in self.config.IMDb.genres:
new_genres = self.config.imdb.genres[imdb_id] new_genres = self.config.IMDb.genres[imdb_id]
elif omdb_item and self.library.mass_genre_update == "omdb": elif omdb_item and self.library.mass_genre_update == "omdb":
new_genres = omdb_item.genres new_genres = omdb_item.genres
elif tvdb_item and self.library.mass_genre_update == "tvdb": elif tvdb_item and self.library.mass_genre_update == "tvdb":

@ -121,7 +121,7 @@ class Overlays:
overlay = properties[over_name] overlay = properties[over_name]
if overlay.name in util.special_text_overlays: if overlay.name in util.special_text_overlays:
rating_type = overlay.name[5:-1] rating_type = overlay.name[5:-1]
if rating_type.endswith(("%", "#")): if rating_type.endswith(tuple(util.rating_mods)):
rating_type = rating_type[:-1] rating_type = rating_type[:-1]
cache_rating = self.config.Cache.query_overlay_ratings(item.ratingKey, rating_type) cache_rating = self.config.Cache.query_overlay_ratings(item.ratingKey, rating_type)
actual = plex.attribute_translation[rating_type] actual = plex.attribute_translation[rating_type]
@ -189,18 +189,17 @@ class Overlays:
def get_text(text): def get_text(text):
text = text[5:-1] text = text[5:-1]
if f"text({text})" in util.special_text_overlays: if f"text({text})" in util.special_text_overlays:
per = text.endswith("%") rating_code = text[-1:]
flat = text.endswith("#") text_rating_type = text[:-1] if rating_code in util.rating_mods else text
text_rating_type = text[:-1] if per or flat else text
text_actual = plex.attribute_translation[text_rating_type] text_actual = plex.attribute_translation[text_rating_type]
if not hasattr(item, text_actual) or getattr(item, text_actual) is None: if not hasattr(item, text_actual) or getattr(item, text_actual) is None:
raise Failed(f"Overlay Warning: No {text_rating_type} found") raise Failed(f"Overlay Warning: No {text_rating_type} found")
text = getattr(item, text_actual) text = getattr(item, text_actual)
if self.config.Cache: if self.config.Cache:
self.config.Cache.update_overlay_ratings(item.ratingKey, text_rating_type, text) self.config.Cache.update_overlay_ratings(item.ratingKey, text_rating_type, text)
if per: if rating_code in ["%", "0"]:
text = f"{int(text * 10)}%" text = f"{int(text * 10)}{'%' if rating_code == '%' else ''}"
if flat and str(text).endswith(".0"): if rating_code == "#" and str(text).endswith(".0"):
text = str(text)[:-2] text = str(text)[:-2]
return str(text) return str(text)

@ -289,7 +289,7 @@ searches = boolean_attributes + \
[f"{f}{m}" for f in tag_attributes + year_attributes for m in tag_modifiers if f not in no_not_mods or m != ".not"] + \ [f"{f}{m}" for f in tag_attributes + year_attributes for m in tag_modifiers if f not in no_not_mods or m != ".not"] + \
[f"{f}{m}" for f in date_attributes for m in date_modifiers] + \ [f"{f}{m}" for f in date_attributes for m in date_modifiers] + \
[f"{f}{m}" for f in number_attributes for m in number_modifiers if f not in no_not_mods] + \ [f"{f}{m}" for f in number_attributes for m in number_modifiers if f not in no_not_mods] + \
[f"{f}{m}" for f in float_attributes for m in float_modifiers if f != "duration" and m != ".rated"] [f"{f}{m}" for f in float_attributes for m in float_modifiers if f != "duration" or m != ".rated"]
music_searches = [a for a in searches if a.startswith(("artist", "album", "track"))] music_searches = [a for a in searches if a.startswith(("artist", "album", "track"))]
movie_sorts = { movie_sorts = {
"title.asc": "titleSort", "title.desc": "titleSort%3Adesc", "title.asc": "titleSort", "title.desc": "titleSort%3Adesc",

@ -93,7 +93,8 @@ parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in pare
github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/" github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/"
previous_time = None previous_time = None
start_time = None start_time = None
special_text_overlays = [f"text({a}{s})" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "%", "#"]] rating_mods = ["0", "%", "#"]
special_text_overlays = [f"text({a}{s})" for a in ["audience_rating", "critic_rating", "user_rating"] for s in [""] + rating_mods]
def make_ordinal(n): def make_ordinal(n):
return f"{n}{'th' if 11 <= (n % 100) <= 13 else ['th', 'st', 'nd', 'rd', 'th'][min(n % 10, 4)]}" return f"{n}{'th' if 11 <= (n % 100) <= 13 else ['th', 'st', 'nd', 'rd', 'th'][min(n % 10, 4)]}"
@ -902,9 +903,10 @@ def parse_cords(data, parent, required=False):
class Overlay: class Overlay:
def __init__(self, config, library, overlay_data, suppress): def __init__(self, config, library, original_mapping_name, overlay_data, suppress):
self.config = config self.config = config
self.library = library self.library = library
self.original_mapping_name = original_mapping_name
self.data = overlay_data self.data = overlay_data
self.suppress = suppress self.suppress = suppress
self.keys = [] self.keys = []
@ -934,15 +936,15 @@ class Overlay:
if "name" not in self.data or not self.data["name"]: if "name" not in self.data or not self.data["name"]:
raise Failed(f"Overlay Error: overlay must have the name attribute") raise Failed(f"Overlay Error: overlay must have the name attribute")
self.name = str(self.data["name"]) self.name = str(self.data["name"])
if self.name not in library.overlay_names: if self.original_mapping_name not in library.overlay_names:
library.overlay_names.append(self.name) library.overlay_names.append(self.original_mapping_name)
self.mapping_name = self.name self.mapping_name = self.original_mapping_name
else: else:
name_count = 1 name_count = 1
test_name = f"{self.name} ({name_count})" test_name = f"{self.original_mapping_name} ({name_count})"
while test_name in library.overlay_names: while test_name in library.overlay_names:
name_count += 1 name_count += 1
test_name = f"{self.name} ({name_count})" test_name = f"{self.original_mapping_name} ({name_count})"
library.overlay_names.append(test_name) library.overlay_names.append(test_name)
self.mapping_name = test_name self.mapping_name = test_name

Loading…
Cancel
Save