mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-11 06:16:35 +08:00
Updates include/exclude tags to be more flexible
This commit is contained in:
parent
c341088adc
commit
cf3cfc4470
4 changed files with 60 additions and 16 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
3.6.4-develop3
|
3.6.4-develop4
|
||||||
|
|
|
@ -146,12 +146,23 @@ share_limits:
|
||||||
noHL:
|
noHL:
|
||||||
# <MANDATORY> priority: <int/float> # This is the priority of your grouping. The lower the number the higher the priority
|
# <MANDATORY> priority: <int/float> # This is the priority of your grouping. The lower the number the higher the priority
|
||||||
priority: 1
|
priority: 1
|
||||||
# <OPTIONAL> tags: <list> # Filter the group based on one or more tags. Multiple tags are checked with an AND condition
|
# <OPTIONAL> include_all_tags: <list> # Filter the group based on one or more tags. Multiple include_all_tags are checked with an AND condition
|
||||||
tags:
|
# All tags defined here must be present in the torrent for it to be included in this group
|
||||||
|
include_all_tags:
|
||||||
- noHL
|
- noHL
|
||||||
# <OPTIONAL> exclude_tags: <list> # Filter by excluding one or more tags. Multiple exclude_tags are checked with an OR condition
|
# <OPTIONAL> include_any_tags: <list> # 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
|
||||||
|
# <OPTIONAL> exclude_all_tags: <list> # 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
|
# 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
|
||||||
|
# <OPTIONAL> exclude_any_tags: <list> # 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
|
- Beyond-HD
|
||||||
# <OPTIONAL> categories: <list> # Filter by excluding one or more categories. Multiple categories are checked with an OR condition
|
# <OPTIONAL> categories: <list> # 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
|
# Since one torrent can only be associated with a single category, multiple categories are checked with an OR condition
|
||||||
|
|
|
@ -322,9 +322,9 @@ class Config:
|
||||||
for group in sorted_share_limits:
|
for group in sorted_share_limits:
|
||||||
self.share_limits[group] = {}
|
self.share_limits[group] = {}
|
||||||
self.share_limits[group]["priority"] = sorted_share_limits[group]["priority"]
|
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,
|
self.data,
|
||||||
"tags",
|
"include_all_tags",
|
||||||
parent="share_limits",
|
parent="share_limits",
|
||||||
subparent=group,
|
subparent=group,
|
||||||
var_type="list",
|
var_type="list",
|
||||||
|
@ -332,9 +332,29 @@ class Config:
|
||||||
do_print=False,
|
do_print=False,
|
||||||
save=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,
|
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",
|
parent="share_limits",
|
||||||
subparent=group,
|
subparent=group,
|
||||||
var_type="list",
|
var_type="list",
|
||||||
|
|
|
@ -244,20 +244,33 @@ class ShareLimits:
|
||||||
def get_share_limit_group(self, tags, category):
|
def get_share_limit_group(self, tags, category):
|
||||||
"""Get the share limit group based on the tags and category of the torrent"""
|
"""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():
|
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"])
|
check_category = self.check_category(category, group_config["categories"])
|
||||||
|
|
||||||
if check_tags and check_category:
|
if check_tags and check_category:
|
||||||
return group_name
|
return group_name
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def check_tags(self, tags, include_tags, exclude_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 and does not have the excluded tags"""
|
"""Check if the torrent has the required tags"""
|
||||||
if include_tags:
|
tags_set = set(tags)
|
||||||
if not set(include_tags).issubset(tags):
|
if include_all_tags:
|
||||||
|
if not set(include_all_tags).issubset(tags_set):
|
||||||
return False
|
return False
|
||||||
if exclude_tags:
|
if include_any_tags:
|
||||||
if set(exclude_tags).intersection(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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue