diff --git a/VERSION b/VERSION index 01f6963a..ff795259 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop63 +1.17.0-develop64 diff --git a/docs/metadata/overlay.md b/docs/metadata/overlay.md index eee0114e..65de3a7b 100644 --- a/docs/metadata/overlay.md +++ b/docs/metadata/overlay.md @@ -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 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. 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` diff --git a/modules/builder.py b/modules/builder.py index f8cd6f7c..7de6c40b 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -260,7 +260,7 @@ class CollectionBuilder: suppress = util.get_list(data[methods["suppress_overlays"]]) else: 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.valid_users = [] diff --git a/modules/operations.py b/modules/operations.py index c6daff7e..71614f9d 100644 --- a/modules/operations.py +++ b/modules/operations.py @@ -200,7 +200,7 @@ class Operations: if tmdb_item and attribute == "tmdb": return tmdb_item.vote_average 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": return omdb_item.imdb_rating elif mdb_item and attribute == "mdb": @@ -234,8 +234,8 @@ class Operations: if self.library.mass_genre_update: if tmdb_item and self.library.mass_genre_update == "tmdb": new_genres = tmdb_item.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] + 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] elif omdb_item and self.library.mass_genre_update == "omdb": new_genres = omdb_item.genres elif tvdb_item and self.library.mass_genre_update == "tvdb": diff --git a/modules/overlays.py b/modules/overlays.py index f30eedbc..1bf7d6bc 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -121,7 +121,7 @@ class Overlays: overlay = properties[over_name] if overlay.name in util.special_text_overlays: rating_type = overlay.name[5:-1] - if rating_type.endswith(("%", "#")): + if rating_type.endswith(tuple(util.rating_mods)): rating_type = rating_type[:-1] cache_rating = self.config.Cache.query_overlay_ratings(item.ratingKey, rating_type) actual = plex.attribute_translation[rating_type] @@ -189,18 +189,17 @@ class Overlays: def get_text(text): text = text[5:-1] if f"text({text})" in util.special_text_overlays: - per = text.endswith("%") - flat = text.endswith("#") - text_rating_type = text[:-1] if per or flat else text + rating_code = text[-1:] + text_rating_type = text[:-1] if rating_code in util.rating_mods else text text_actual = plex.attribute_translation[text_rating_type] if not hasattr(item, text_actual) or getattr(item, text_actual) is None: raise Failed(f"Overlay Warning: No {text_rating_type} found") text = getattr(item, text_actual) if self.config.Cache: self.config.Cache.update_overlay_ratings(item.ratingKey, text_rating_type, text) - if per: - text = f"{int(text * 10)}%" - if flat and str(text).endswith(".0"): + if rating_code in ["%", "0"]: + text = f"{int(text * 10)}{'%' if rating_code == '%' else ''}" + if rating_code == "#" and str(text).endswith(".0"): text = str(text)[:-2] return str(text) @@ -306,7 +305,7 @@ class Overlays: logger.separator(f"Gathering Items for {k} Overlay", space=False, border=False) if builder.overlay.mapping_name in properties: - raise Failed(f"Overlay Error: Overlay {builder.overlay.mapping_name} already exists ") + raise Failed(f"Overlay Error: Overlay {builder.overlay.mapping_name} already exists") properties[builder.overlay.mapping_name] = builder.overlay for method, value in builder.builders: diff --git a/modules/plex.py b/modules/plex.py index 88691c35..fc9efc6a 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -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 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 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"))] movie_sorts = { "title.asc": "titleSort", "title.desc": "titleSort%3Adesc", diff --git a/modules/util.py b/modules/util.py index 272a75d4..e05c14d9 100644 --- a/modules/util.py +++ b/modules/util.py @@ -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/" previous_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): 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: - def __init__(self, config, library, overlay_data, suppress): + def __init__(self, config, library, original_mapping_name, overlay_data, suppress): self.config = config self.library = library + self.original_mapping_name = original_mapping_name self.data = overlay_data self.suppress = suppress self.keys = [] @@ -934,15 +936,15 @@ class Overlay: if "name" not in self.data or not self.data["name"]: raise Failed(f"Overlay Error: overlay must have the name attribute") self.name = str(self.data["name"]) - if self.name not in library.overlay_names: - library.overlay_names.append(self.name) - self.mapping_name = self.name + if self.original_mapping_name not in library.overlay_names: + library.overlay_names.append(self.original_mapping_name) + self.mapping_name = self.original_mapping_name else: 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: 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) self.mapping_name = test_name