added has_collection filter

pull/503/head
meisnate12 3 years ago
parent 7c10227176
commit d0642f818e

@ -132,7 +132,7 @@ all_filters = [
"studio", "studio.not", "studio.is", "studio.isnot", "studio.begins", "studio.ends", "studio.regex", "studio", "studio.not", "studio.is", "studio.isnot", "studio.begins", "studio.ends", "studio.regex",
"subtitle_language", "subtitle_language.not", "subtitle_language", "subtitle_language.not",
"resolution", "resolution.not", "resolution", "resolution.not",
"writer", "writer.not", "writer", "writer.not", "has_collection",
"year", "year.gt", "year.gte", "year.lt", "year.lte", "year.not" "year", "year.gt", "year.gte", "year.lt", "year.lte", "year.not"
"tmdb_year", "tmdb_year.gt", "tmdb_year.gte", "tmdb_year.lt", "tmdb_year.lte", "tmdb_year.not" "tmdb_year", "tmdb_year.gt", "tmdb_year.gte", "tmdb_year.lt", "tmdb_year.lte", "tmdb_year.not"
] ]
@ -1587,7 +1587,7 @@ class CollectionBuilder:
for value in values: for value in values:
final_years.append(util.parse(final, value, datatype="int", minimum=1800, maximum=self.current_year)) final_years.append(util.parse(final, value, datatype="int", minimum=1800, maximum=self.current_year))
return smart_pair(final_years) return smart_pair(final_years)
elif attribute in plex.boolean_attributes: elif attribute in plex.boolean_attributes + ["has_collection"]:
return util.parse(attribute, data, datatype="bool") return util.parse(attribute, data, datatype="bool")
else: else:
raise Failed(f"Collection Error: {final} attribute not supported") raise Failed(f"Collection Error: {final} attribute not supported")
@ -1747,6 +1747,9 @@ class CollectionBuilder:
values = [getattr(current, filter_actual)] values = [getattr(current, filter_actual)]
if util.is_string_filter(values, modifier, filter_data): if util.is_string_filter(values, modifier, filter_data):
return False return False
elif filter_attr == "has_collection":
if util.is_boolean_filter(filter_data, len(current.collections) > 0):
return False
elif filter_attr == "history": elif filter_attr == "history":
item_date = current.originallyAvailableAt item_date = current.originallyAvailableAt
if item_date is None: if item_date is None:

@ -309,6 +309,9 @@ def is_number_filter(value, modifier, data):
or (modifier == ".lt" and value >= data) \ or (modifier == ".lt" and value >= data) \
or (modifier == ".lte" and value > data) or (modifier == ".lte" and value > data)
def is_boolean_filter(value, data):
return (data and not value) or (not data and value)
def is_string_filter(values, modifier, data): def is_string_filter(values, modifier, data):
jailbreak = False jailbreak = False
for value in values: for value in values:

Loading…
Cancel
Save