diff --git a/VERSION b/VERSION index ace855b..03c481d 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.4-develop3 +3.6.4-develop4 diff --git a/config/config.yml.sample b/config/config.yml.sample index 9427f9a..2c50036 100755 --- a/config/config.yml.sample +++ b/config/config.yml.sample @@ -146,12 +146,23 @@ share_limits: noHL: # priority: # This is the priority of your grouping. The lower the number the higher the priority priority: 1 - # tags: # Filter the group based on one or more tags. Multiple tags are checked with an AND condition - tags: + # include_all_tags: # Filter the group based on one or more tags. Multiple include_all_tags are checked with an AND condition + # All tags defined here must be present in the torrent for it to be included in this group + include_all_tags: - noHL - # exclude_tags: # Filter by excluding one or more tags. Multiple exclude_tags are checked with an OR condition + # include_any_tags: # Filter the group based on one or more tags. Multiple include_any_tags are checked with an OR condition + # Any tags defined here must be present in the torrent for it to be included in this group + include_any_tags: + - noHL + # exclude_all_tags: # Filter by excluding one or more tags. Multiple exclude_all_tags are checked with an AND condition # This is useful to combine with the category filter to exclude one or more tags from an entire category - exclude_tags: + # All tags defined here must be present in the torrent for it to be excluded in this group + exclude_all_tags: + - Beyond-HD + # exclude_any_tags: # Filter by excluding one or more tags. Multiple exclude_any_tags are checked with an OR condition + # This is useful to combine with the category filter to exclude one or more tags from an entire category + # Any tags defined here must be present in the torrent for it to be excluded in this group + exclude_any_tags: - Beyond-HD # categories: # Filter by excluding one or more categories. Multiple categories are checked with an OR condition # Since one torrent can only be associated with a single category, multiple categories are checked with an OR condition diff --git a/modules/config.py b/modules/config.py index ab2b6c5..ecad953 100755 --- a/modules/config.py +++ b/modules/config.py @@ -322,9 +322,9 @@ class Config: for group in sorted_share_limits: self.share_limits[group] = {} self.share_limits[group]["priority"] = sorted_share_limits[group]["priority"] - self.share_limits[group]["tags"] = self.util.check_for_attribute( + self.share_limits[group]["include_all_tags"] = self.util.check_for_attribute( self.data, - "tags", + "include_all_tags", parent="share_limits", subparent=group, var_type="list", @@ -332,9 +332,29 @@ class Config: do_print=False, save=False, ) - self.share_limits[group]["exclude_tags"] = self.util.check_for_attribute( + self.share_limits[group]["include_any_tags"] = self.util.check_for_attribute( self.data, - "exclude_tags", + "include_any_tags", + parent="share_limits", + subparent=group, + var_type="list", + default_is_none=True, + do_print=False, + save=False, + ) + self.share_limits[group]["exclude_all_tags"] = self.util.check_for_attribute( + self.data, + "exclude_all_tags", + parent="share_limits", + subparent=group, + var_type="list", + default_is_none=True, + do_print=False, + save=False, + ) + self.share_limits[group]["exclude_any_tags"] = self.util.check_for_attribute( + self.data, + "exclude_any_tags", parent="share_limits", subparent=group, var_type="list", diff --git a/modules/core/share_limits.py b/modules/core/share_limits.py index 2e70ace..b67239b 100644 --- a/modules/core/share_limits.py +++ b/modules/core/share_limits.py @@ -244,20 +244,33 @@ class ShareLimits: def get_share_limit_group(self, tags, category): """Get the share limit group based on the tags and category of the torrent""" for group_name, group_config in self.share_limits_config.items(): - check_tags = self.check_tags(tags, group_config["tags"], group_config["exclude_tags"]) + check_tags = self.check_tags( + tags=tags, + include_all_tags=group_config["include_all_tags"], + include_any_tags=group_config["include_any_tags"], + exclude_all_tags=group_config["exclude_all_tags"], + exclude_any_tags=group_config["exclude_any_tags"], + ) check_category = self.check_category(category, group_config["categories"]) if check_tags and check_category: return group_name return None - def check_tags(self, tags, include_tags, exclude_tags): - """Check if the torrent has the required tags and does not have the excluded tags""" - if include_tags: - if not set(include_tags).issubset(tags): + def check_tags(self, tags, include_all_tags=set(), include_any_tags=set(), exclude_all_tags=set(), exclude_any_tags=set()): + """Check if the torrent has the required tags""" + tags_set = set(tags) + if include_all_tags: + if not set(include_all_tags).issubset(tags_set): return False - if exclude_tags: - if set(exclude_tags).intersection(tags): + if include_any_tags: + if not set(include_any_tags).intersection(tags_set): + return False + if exclude_all_tags: + if set(exclude_all_tags).issubset(tags_set): + return False + if exclude_any_tags: + if set(exclude_any_tags).intersection(tags_set): return False return True