Skip to content

Commit

Permalink
fix 过滤规则Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Jul 19, 2023
1 parent 1ce7e62 commit 4327725
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ docker pull jxxghp/moviepilot:latest

`设定`-`规则`中设定,规则说明:

- 仅支持使用内置规则进行排列组合,内置规则有:`BLU``4K``1080P``CNSUB``SPECSUB``H265``H264``DOLBY``HDR``REMUX``WEBDL``FREE`
- 仅支持使用内置规则进行排列组合,内置规则有:`蓝光原盘``4K``1080P``中文字幕``特效字幕``H265``H264``杜比``HDR``REMUX``WEB-DL``免费``国语配音`
- `&`表示与,``表示或,`!`表示非,`>`表示优先级层级
- 符合任一层级规则的资源将被标识选中,匹配成功的层级做为该资源的优先级,排越前面优先级超高
- 不符合过滤规则所有层级规则的资源将不会被选中
Expand Down
5 changes: 3 additions & 2 deletions app/helper/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def get_sort_str(_context):
"""
_meta = _context.meta_info
_torrent = _context.torrent_info
_media = _context.media_info
# 站点优先级
_site_order = 999 - (_torrent.site_order or 0)
# 季数
Expand All @@ -192,13 +193,13 @@ def get_sort_str(_context):
priority = self.system_config.get(SystemConfigKey.TorrentsPriority)
if priority != "site":
# 排序:标题、资源类型、做种、季集
return "%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
return "%s%s%s%s" % (str(_media.title).ljust(100, ' '),
str(_torrent.pri_order).rjust(3, '0'),
str(_torrent.seeders).rjust(10, '0'),
"%s%s" % (_season_len, _episode_len))
else:
# 排序:标题、资源类型、站点、做种、季集
return "%s%s%s%s%s" % (str(_torrent.title).ljust(100, ' '),
return "%s%s%s%s%s" % (str(_media.title).ljust(100, ' '),
str(_torrent.pri_order).rjust(3, '0'),
str(_site_order).rjust(3, '0'),
str(_torrent.seeders).rjust(10, '0'),
Expand Down
15 changes: 10 additions & 5 deletions app/modules/filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FilterModule(_ModuleBase):
},
# 中字
"CNSUB": {
"include": [r'[中国國繁简](/|\s|\\|\|)?[繁简英粤]|[英简繁](/|\s|\\|\|)?[中繁简]|繁體|简体|[中国國][字配]|国语|國語|中文'],
"include": [r'[中国國繁简](/|\s|\\|\|)?[繁简英粤]|[英简繁](/|\s|\\|\|)?[中繁简]|繁體|简体|[中国國][字配]|国语|國語|中文|中字'],
"exclude": []
},
# 特效字幕
Expand All @@ -52,12 +52,12 @@ class FilterModule(_ModuleBase):
},
# 杜比
"DOLBY": {
"include": [r"DOLBY|DOVI|\s+DV$|\s+DV\s+"],
"include": [r"DOLBY|DOVI|[\s.]+DV[\s.]+|杜比"],
"exclude": []
},
# HDR
"HDR": {
"include": [r"\s+HDR\s+|HDR10|HDR10\+"],
"include": [r"[\s.]+HDR[\s.]+|HDR10|HDR10\+"],
"exclude": []
},
# 重编码
Expand All @@ -73,6 +73,11 @@ class FilterModule(_ModuleBase):
# 免费
"FREE": {
"downloadvolumefactor": 0
},
# 国语配音
"CNVOI": {
"include": [r'国语配音|国配'],
"exclude": []
}
}

Expand Down Expand Up @@ -176,7 +181,7 @@ def __match_group(self, torrent: TorrentInfo, rule_group: Union[list, str]) -> b
return self.__match_rule(torrent, rule_group)
elif isinstance(rule_group, list) and len(rule_group) == 1:
# 只有一个规则项
return self.__match_rule(torrent, rule_group[0])
return self.__match_group(torrent, rule_group[0])
elif rule_group[0] == "not":
# 非操作
return not self.__match_group(torrent, rule_group[1:])
Expand All @@ -201,7 +206,7 @@ def __match_rule(self, torrent: TorrentInfo, rule_name: str) -> bool:
# FREE规则
downloadvolumefactor = self.rule_set[rule_name].get("downloadvolumefactor")
# 匹配项
content = f"{torrent.title} {torrent.description}"
content = f"{torrent.title} {torrent.description} {' '.join(torrent.labels or [])}"
for include in includes:
if not re.search(r"%s" % include, content, re.IGNORECASE):
# 未发现包含项
Expand Down

0 comments on commit 4327725

Please sign in to comment.