diff --git a/modules/builder.py b/modules/builder.py index 022adee2..87986f1c 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -132,7 +132,7 @@ all_filters = [ "studio", "studio.not", "studio.is", "studio.isnot", "studio.begins", "studio.ends", "studio.regex", "subtitle_language", "subtitle_language.not", "resolution", "resolution.not", - "writer", "writer.not", + "writer", "writer.not", "has_collection", "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" ] @@ -1587,7 +1587,7 @@ class CollectionBuilder: for value in values: final_years.append(util.parse(final, value, datatype="int", minimum=1800, maximum=self.current_year)) 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") else: raise Failed(f"Collection Error: {final} attribute not supported") @@ -1747,6 +1747,9 @@ class CollectionBuilder: values = [getattr(current, filter_actual)] if util.is_string_filter(values, modifier, filter_data): return False + elif filter_attr == "has_collection": + if util.is_boolean_filter(filter_data, len(current.collections) > 0): + return False elif filter_attr == "history": item_date = current.originallyAvailableAt if item_date is None: diff --git a/modules/util.py b/modules/util.py index 2e01c5af..39ea0622 100644 --- a/modules/util.py +++ b/modules/util.py @@ -309,6 +309,9 @@ def is_number_filter(value, modifier, data): or (modifier == ".lt" 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): jailbreak = False for value in values: