From fb03658c726d756fe304009a5fe81a6b3bf1dd14 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 26 Jun 2022 15:08:17 -0400 Subject: [PATCH] [61] add .rated --- VERSION | 2 +- docs/metadata/builders/plex.md | 5 ++++- docs/metadata/builders/smart.md | 5 ++++- modules/builder.py | 4 +++- modules/meta.py | 10 ++++++++-- modules/overlays.py | 2 +- modules/plex.py | 14 ++++++++------ 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index 48978ebb..e2677537 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop60 +1.17.0-develop61 diff --git a/docs/metadata/builders/plex.md b/docs/metadata/builders/plex.md index f14835a9..4b918d8f 100644 --- a/docs/metadata/builders/plex.md +++ b/docs/metadata/builders/plex.md @@ -247,7 +247,7 @@ No date search can take multiple values. ## Number Searches -Number searches must use `.gt`, `.gte`, `.lt`, or `.lte` as a modifier. +Number searches must use `.gt`, `.gte`, `.lt`, or `.lte` as a modifier only the rating searches can use `.rated`. No number search can take multiple values. @@ -259,6 +259,9 @@ No number search can take multiple values. | `.gte` | Matches every item where the number attribute is greater than or equal to the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | N/A | | `.lt` | Matches every item where the number attribute is less than the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | `is less than` | | `.lte` | Matches every item where the number attribute is less than or equal to the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | N/A | +| `.rated` | Matches every item either rated or not rated
**Format:** `true` or `false` | N/A | + +* `.rated` only works for rating searches ### Number Attributes diff --git a/docs/metadata/builders/smart.md b/docs/metadata/builders/smart.md index 0fda35f9..8f474c87 100644 --- a/docs/metadata/builders/smart.md +++ b/docs/metadata/builders/smart.md @@ -215,7 +215,7 @@ No date filter can take multiple values. ## Number Filters -Number filters must use `.gt`, `.gte`, `.lt`, or `.lte` as a modifier. +Number filters must use `.gt`, `.gte`, `.lt`, or `.lte` as a modifier only the rating filters can use `.rated`. No number filter can take multiple values. @@ -227,6 +227,9 @@ No number filter can take multiple values. | `.gte` | Matches every item where the number attribute is greater than or equal to the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | N/A | | `.lt` | Matches every item where the number attribute is less than the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | `is less than` | | `.lte` | Matches every item where the number attribute is less than or equal to the given number
**Format:** number
**Example:** `30`, `1995`, or `7.5` | N/A | +| `.rated` | Matches every item either rated or not rated
**Format:** `true` or `false` | N/A | + +* `.rated` only works for rating filters ### Number Attributes diff --git a/modules/builder.py b/modules/builder.py index 9f133038..f8cd6f7c 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1802,6 +1802,8 @@ class CollectionBuilder: results, display_add = build_url_arg(f"-{validation}", mod=last_mod, arg_s=f"{validation} {plex.date_sub_mods[search_mod]}", mod_s=last_text) elif attr == "duration" and modifier in [".gt", ".gte", ".lt", ".lte"]: results, display_add = build_url_arg(validation * 60000) + elif modifier == ".rated": + results, display_add = build_url_arg(-1, mod="%3D" if validation else "!%3D", arg_s="Rated", mod_s="is" if validation else "is not") elif attr in plex.boolean_attributes: bool_mod = "" if validation else "!" bool_arg = "true" if validation else "false" @@ -1962,7 +1964,7 @@ class CollectionBuilder: return util.parse(self.Type, final, data, datatype="int", minimum=0) elif attribute in float_attributes and modifier in ["", ".not", ".gt", ".gte", ".lt", ".lte"]: return util.parse(self.Type, final, data, datatype="float", minimum=0, maximum=None if attribute == "duration" else 10) - elif attribute in boolean_attributes: + elif attribute in boolean_attributes or (attribute in float_attributes and modifier in [".rated"]): return util.parse(self.Type, attribute, data, datatype="bool") elif attribute in ["seasons", "episodes", "albums", "tracks"]: if isinstance(data, dict) and data: diff --git a/modules/meta.py b/modules/meta.py index e2ce0632..fb2184dd 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -73,9 +73,15 @@ class DataFile: def get_file_name(self): data = f"{util.github_base}{self.path}.yml" if self.type == "GIT" else self.path if "/" in data: - return data[data.rfind("/") + 1:-4] + if data.endswith(".yml"): + return data[data.rfind("/") + 1:-4] + else: + return data[data.rfind("/") + 1:] elif "\\" in data: - return data[data.rfind("\\") + 1:-4] + if data.endswith(".yml"): + return data[data.rfind("\\") + 1:-4] + else: + return data[data.rfind("\\") + 1:] else: return data diff --git a/modules/overlays.py b/modules/overlays.py index ead743a9..f30eedbc 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -70,7 +70,7 @@ class Overlays: logger.info("") if not self.library.remove_overlays: logger.info("") - logger.separator(f"Applying Overlays for the {self.library.name} Library") + logger.separator(f"{'Re-' if self.library.reapply_overlays else ''}Applying Overlays for the {self.library.name} Library") logger.info("") for i, (over_key, (item, over_names)) in enumerate(sorted(key_to_overlays.items(), key=lambda io: self.library.get_item_sort_title(io[1][0])), 1): try: diff --git a/modules/plex.py b/modules/plex.py index c113cc23..88691c35 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -117,7 +117,7 @@ show_translation = { } modifier_translation = { "": "", ".not": "!", ".is": "%3D", ".isnot": "!%3D", ".gt": "%3E%3E", ".gte": "%3E", ".lt": "%3C%3C", ".lte": "%3C", - ".before": "%3C%3C", ".after": "%3E%3E", ".begins": "%3C", ".ends": "%3E", ".regex": "" + ".before": "%3C%3C", ".after": "%3E%3E", ".begins": "%3C", ".ends": "%3E", ".regex": "", ".rated": "" } attribute_translation = { "aspect": "aspectRatio", @@ -248,9 +248,9 @@ show_only_searches = [ "episode_air_date.before", "episode_air_date.after", "episode_last_played", "episode_last_played.not", "episode_last_played.before", "episode_last_played.after", "episode_plays.gt", "episode_plays.gte", "episode_plays.lt", "episode_plays.lte", - "episode_user_rating.gt", "episode_user_rating.gte", "episode_user_rating.lt", "episode_user_rating.lte", - "episode_critic_rating.gt", "episode_critic_rating.gte", "episode_critic_rating.lt", "episode_critic_rating.lte", - "episode_audience_rating.gt", "episode_audience_rating.gte", "episode_audience_rating.lt", "episode_audience_rating.lte", + "episode_user_rating.gt", "episode_user_rating.gte", "episode_user_rating.lt", "episode_user_rating.lte", "episode_user_rating.rated", + "episode_critic_rating.gt", "episode_critic_rating.gte", "episode_critic_rating.lt", "episode_critic_rating.lte", "episode_critic_rating.rated", + "episode_audience_rating.gt", "episode_audience_rating.gte", "episode_audience_rating.lt", "episode_audience_rating.lte", "episode_audience_rating.rated", "episode_year", "episode_year.not", "episode_year.gt", "episode_year.gte", "episode_year.lt", "episode_year.lte", "unplayed_episodes", "episode_unplayed", "episode_duplicate", "episode_progress", "episode_unmatched", "show_unmatched", ] @@ -269,11 +269,12 @@ date_attributes = [ date_modifiers = ["", ".not", ".before", ".after"] year_attributes = ["decade", "year", "episode_year", "album_year", "album_decade"] number_attributes = ["plays", "episode_plays", "album_plays", "track_plays", "track_skips"] + year_attributes +number_modifiers = [".gt", ".gte", ".lt", ".lte"] float_attributes = [ "user_rating", "episode_user_rating", "critic_rating", "episode_critic_rating", "audience_rating", "episode_audience_rating", "duration", "artist_user_rating", "album_user_rating", "album_critic_rating", "track_user_rating" ] -number_modifiers = [".gt", ".gte", ".lt", ".lte"] +float_modifiers = number_modifiers + [".rated"] search_display = {"added": "Date Added", "release": "Release Date", "hdr": "HDR", "progress": "In Progress", "episode_progress": "Episode In Progress"} tag_attributes = [ "actor", "audio_language", "collection", "content_rating", "country", "director", "genre", "label", "network", @@ -287,7 +288,8 @@ searches = boolean_attributes + \ [f"{f}{m}" for f in string_attributes for m in string_modifiers] + \ [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 + float_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"] music_searches = [a for a in searches if a.startswith(("artist", "album", "track"))] movie_sorts = { "title.asc": "titleSort", "title.desc": "titleSort%3Adesc",