#187 added user_rating plex_search and filter

pull/211/head
meisnate12 4 years ago
parent 96ea7baffe
commit d1698b4814

@ -123,6 +123,7 @@ all_filters = [
"tmdb_vote_count.gte", "tmdb_vote_count.lte", "tmdb_vote_count.gte", "tmdb_vote_count.lte",
"duration.gte", "duration.lte", "duration.gte", "duration.lte",
"original_language", "original_language.not", "original_language", "original_language.not",
"user_rating.gte", "user_rating.lte",
"audience_rating.gte", "audience_rating.lte", "audience_rating.gte", "audience_rating.lte",
"critic_rating.gte", "critic_rating.lte", "critic_rating.gte", "critic_rating.lte",
"studio", "studio.not", "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)}])) 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"]: 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)}])) 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)}])) 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"]: 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)}])) 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) valid_data = util.check_number(filter_data, f"{filter_method} filter", minimum=1)
elif filter_method in ["year.gte", "year.lte"]: elif filter_method in ["year.gte", "year.lte"]:
valid_data = util.check_year(filter_data, current_year, f"{filter_method} filter") 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) 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"]: elif filter_method in ["originally_available.gte", "originally_available.lte"]:
valid_data = util.check_date(filter_data, f"{filter_method} filter") 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) 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"]): 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) 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) 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"]): 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) 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 ["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 ["resolution", "decade"] and modifier not in [""]) \
or (search in ["added", "originally_available"] and modifier not in ["", ".not", ".before", ".after"]) \ 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"]): 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") raise Failed(f"Collection Error: modifier: {modifier} not supported with the {search} plex search attribute")
else: else:

@ -20,7 +20,8 @@ search_translation = {
"added": "addedAt", "added": "addedAt",
"originally_available": "originallyAvailableAt", "originally_available": "originallyAvailableAt",
"audience_rating": "audienceRating", "audience_rating": "audienceRating",
"critic_rating": "rating" "critic_rating": "rating",
"user_rating": "userRating"
} }
episode_sorting_options = {"default": "-1", "oldest": "0", "newest": "1"} 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} 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", "genre": "genres",
"originally_available": "originallyAvailableAt", "originally_available": "originallyAvailableAt",
"tmdb_vote_count": "vote_count", "tmdb_vote_count": "vote_count",
"user_rating": "userRating",
"writer": "writers" "writer": "writers"
} }
searches = [ searches = [
@ -66,6 +68,7 @@ searches = [
"added.before", "added.after", "added.before", "added.after",
"originally_available.before", "originally_available.after", "originally_available.before", "originally_available.after",
"duration.greater", "duration.less", "duration.greater", "duration.less",
"user_rating.greater", "user_rating.less",
"audience_rating.greater", "audience_rating.less", "audience_rating.greater", "audience_rating.less",
"critic_rating.greater", "critic_rating.less", "critic_rating.greater", "critic_rating.less",
"year", "year.not", "year.greater", "year.less" "year", "year.not", "year.greater", "year.less"
@ -252,9 +255,9 @@ class PlexAPI:
else: else:
search, modifier = os.path.splitext(str(search_method).lower()) search, modifier = os.path.splitext(str(search_method).lower())
final_search = search_translation[search] if search in search_translation else search 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 = ">>" final_mod = ">>"
elif search == "originally_available" and modifier == ".not": elif search in ["added", "originally_available"] and modifier == ".not":
final_mod = "<<" final_mod = "<<"
elif search in ["critic_rating", "audience_rating"] and modifier == ".greater": elif search in ["critic_rating", "audience_rating"] and modifier == ".greater":
final_mod = "__gte" final_mod = "__gte"

Loading…
Cancel
Save