diff --git a/modules/builder.py b/modules/builder.py index 836d96e3..f109e025 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -123,6 +123,7 @@ all_filters = [ "tmdb_vote_count.gte", "tmdb_vote_count.lte", "duration.gte", "duration.lte", "original_language", "original_language.not", + "user_rating.gte", "user_rating.lte", "audience_rating.gte", "audience_rating.lte", "critic_rating.gte", "critic_rating.lte", "studio", "studio.not", @@ -512,7 +513,7 @@ class CollectionBuilder: self.methods.append(("plex_search", [{method_name: util.check_date(method_data, method_name, return_string=True, plex_date=True)}])) elif method_name in ["added", "added.not", "originally_available", "originally_available.not", "duration.greater", "duration.less"]: self.methods.append(("plex_search", [{method_name: util.check_number(method_data, method_name, minimum=1)}])) - elif method_name in ["critic_rating.greater", "critic_rating.less", "audience_rating.greater", "audience_rating.less"]: + elif method_name in ["user_rating.greater", "user_rating.less", "critic_rating.greater", "critic_rating.less", "audience_rating.greater", "audience_rating.less"]: self.methods.append(("plex_search", [{method_name: util.check_number(method_data, method_name, number_type="float", minimum=0, maximum=10)}])) elif method_name in ["decade", "year", "year.not"]: self.methods.append(("plex_search", [{method_name: util.get_year_list(method_data, current_year, method_name)}])) @@ -619,7 +620,7 @@ class CollectionBuilder: valid_data = util.check_number(filter_data, f"{filter_method} filter", minimum=1) elif filter_method in ["year.gte", "year.lte"]: valid_data = util.check_year(filter_data, current_year, f"{filter_method} filter") - elif filter_method in ["audience_rating.gte", "audience_rating.lte", "critic_rating.gte", "critic_rating.lte"]: + elif filter_method in ["user_rating.gte", "user_rating.lte", "audience_rating.gte", "audience_rating.lte", "critic_rating.gte", "critic_rating.lte"]: valid_data = util.check_number(filter_data, f"{filter_method} filter", number_type="float", minimum=0.1, maximum=10) elif filter_method in ["originally_available.gte", "originally_available.lte"]: valid_data = util.check_date(filter_data, f"{filter_method} filter") @@ -704,7 +705,7 @@ class CollectionBuilder: searches[search_final] = util.check_date(search_data, search_final, return_string=True, plex_date=True) elif (search in ["added", "originally_available"] and modifier in ["", ".not"]) or (search in ["duration"] and modifier in [".greater", ".less"]): searches[search_final] = util.check_number(search_data, search_final, minimum=1) - elif search in ["critic_rating", "audience_rating"] and modifier in [".greater", ".less"]: + elif search in ["user_rating", "critic_rating", "audience_rating"] and modifier in [".greater", ".less"]: searches[search_final] = util.check_number(search_data, search_final, number_type="float", minimum=0, maximum=10) elif (search == "decade" and modifier in [""]) or (search == "year" and modifier in ["", ".not"]): searches[search_final] = util.get_year_list(search_data, current_year, search_final) @@ -712,7 +713,7 @@ class CollectionBuilder: or (search in ["actor", "audio_language", "collection", "content_rating", "country", "director", "genre", "label", "network", "producer", "subtitle_language", "writer"] and modifier not in ["", ".and", ".not"]) \ or (search in ["resolution", "decade"] and modifier not in [""]) \ or (search in ["added", "originally_available"] and modifier not in ["", ".not", ".before", ".after"]) \ - or (search in ["duration", "critic_rating", "audience_rating"] and modifier not in [".greater", ".less"]) \ + or (search in ["duration", "user_rating", "critic_rating", "audience_rating"] and modifier not in [".greater", ".less"]) \ or (search in ["year"] and modifier not in ["", ".not", ".greater", ".less"]): raise Failed(f"Collection Error: modifier: {modifier} not supported with the {search} plex search attribute") else: diff --git a/modules/plex.py b/modules/plex.py index 5ce92a85..c56faa06 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -20,7 +20,8 @@ search_translation = { "added": "addedAt", "originally_available": "originallyAvailableAt", "audience_rating": "audienceRating", - "critic_rating": "rating" + "critic_rating": "rating", + "user_rating": "userRating" } episode_sorting_options = {"default": "-1", "oldest": "0", "newest": "1"} keep_episodes_options = {"all": 0, "5_latest": 5, "3_latest": 3, "latest": 1, "past_3": -3, "past_7": -7, "past_30": -30} @@ -45,6 +46,7 @@ filter_alias = { "genre": "genres", "originally_available": "originallyAvailableAt", "tmdb_vote_count": "vote_count", + "user_rating": "userRating", "writer": "writers" } searches = [ @@ -66,6 +68,7 @@ searches = [ "added.before", "added.after", "originally_available.before", "originally_available.after", "duration.greater", "duration.less", + "user_rating.greater", "user_rating.less", "audience_rating.greater", "audience_rating.less", "critic_rating.greater", "critic_rating.less", "year", "year.not", "year.greater", "year.less" @@ -252,9 +255,9 @@ class PlexAPI: else: search, modifier = os.path.splitext(str(search_method).lower()) final_search = search_translation[search] if search in search_translation else search - if search == "originally_available" and modifier == "": + if search in ["added", "originally_available"] and modifier == "": final_mod = ">>" - elif search == "originally_available" and modifier == ".not": + elif search in ["added", "originally_available"] and modifier == ".not": final_mod = "<<" elif search in ["critic_rating", "audience_rating"] and modifier == ".greater": final_mod = "__gte"