mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
fix torrent filter
This commit is contained in:
@@ -718,6 +718,11 @@ class SubscribeChain(ChainBase):
|
|||||||
logger.info(f'{subscribe.name} 正在洗版,{torrent_info.title} 优先级低于或等于已下载优先级')
|
logger.info(f'{subscribe.name} 正在洗版,{torrent_info.title} 优先级低于或等于已下载优先级')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 匹配订阅参数
|
||||||
|
if not self.torrenthelper.filter_torrent(torrent_info=torrent_info,
|
||||||
|
filter_params=self.get_params(subscribe)):
|
||||||
|
continue
|
||||||
|
|
||||||
# 匹配成功
|
# 匹配成功
|
||||||
logger.info(f'{mediainfo.title_year} 匹配成功:{torrent_info.title}')
|
logger.info(f'{mediainfo.title_year} 匹配成功:{torrent_info.title}')
|
||||||
_match_context.append(context)
|
_match_context.append(context)
|
||||||
@@ -1132,3 +1137,21 @@ class SubscribeChain(ChainBase):
|
|||||||
if not value:
|
if not value:
|
||||||
return None
|
return None
|
||||||
return value.get(default_config_key) or None
|
return value.get(default_config_key) or None
|
||||||
|
|
||||||
|
def get_params(self, subscribe: Subscribe):
|
||||||
|
"""
|
||||||
|
获取订阅默认参数
|
||||||
|
"""
|
||||||
|
# 默认过滤规则
|
||||||
|
default_rule = self.systemconfig.get(SystemConfigKey.SubscribeDefaultParams) or {}
|
||||||
|
return {
|
||||||
|
"include": subscribe.include or default_rule.get("include"),
|
||||||
|
"exclude": subscribe.exclude or default_rule.get("exclude"),
|
||||||
|
"quality": subscribe.quality or default_rule.get("quality"),
|
||||||
|
"resolution": subscribe.resolution or default_rule.get("resolution"),
|
||||||
|
"effect": subscribe.effect or default_rule.get("effect"),
|
||||||
|
"tv_size": default_rule.get("tv_size"),
|
||||||
|
"movie_size": default_rule.get("movie_size"),
|
||||||
|
"min_seeders": default_rule.get("min_seeders"),
|
||||||
|
"min_seeders_time": default_rule.get("min_seeders_time"),
|
||||||
|
}
|
||||||
|
|||||||
+50
-1
@@ -1,7 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Tuple, Optional, List, Union
|
from typing import Tuple, Optional, List, Union, Dict
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from requests import Response
|
from requests import Response
|
||||||
@@ -384,3 +384,52 @@ class TorrentHelper(metaclass=Singleton):
|
|||||||
# 未匹配
|
# 未匹配
|
||||||
logger.debug(f'{torrent.site_name} - {torrent.title} 标题不匹配,识别名称:{meta_names}')
|
logger.debug(f'{torrent.site_name} - {torrent.title} 标题不匹配,识别名称:{meta_names}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_torrent(torrent_info: TorrentInfo,
|
||||||
|
filter_params: Dict[str, str]) -> bool:
|
||||||
|
"""
|
||||||
|
检查种子是否匹配订阅过滤规则
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not filter_params:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# 匹配内容
|
||||||
|
content = (f"{torrent_info.title} "
|
||||||
|
f"{torrent_info.description} "
|
||||||
|
f"{' '.join(torrent_info.labels or [])} "
|
||||||
|
f"{torrent_info.volume_factor}")
|
||||||
|
|
||||||
|
# 包含
|
||||||
|
include = filter_params.get("include")
|
||||||
|
if include:
|
||||||
|
if not re.search(r"%s" % include, content, re.I):
|
||||||
|
logger.info(f"{content} 不匹配包含规则 {include}")
|
||||||
|
return False
|
||||||
|
# 排除
|
||||||
|
exclude = filter_params.get("exclude")
|
||||||
|
if exclude:
|
||||||
|
if re.search(r"%s" % exclude, content, re.I):
|
||||||
|
logger.info(f"{content} 匹配排除规则 {exclude}")
|
||||||
|
return False
|
||||||
|
# 质量
|
||||||
|
quality = filter_params.get("quality")
|
||||||
|
if quality:
|
||||||
|
if not re.search(r"%s" % quality, torrent_info.title, re.I):
|
||||||
|
logger.info(f"{torrent_info.title} 不匹配质量规则 {quality}")
|
||||||
|
return False
|
||||||
|
# 分辨率
|
||||||
|
resolution = filter_params.get("resolution")
|
||||||
|
if resolution:
|
||||||
|
if not re.search(r"%s" % resolution, torrent_info.title, re.I):
|
||||||
|
logger.info(f"{torrent_info.title} 不匹配分辨率规则 {resolution}")
|
||||||
|
return False
|
||||||
|
# 特效
|
||||||
|
effect = filter_params.get("effect")
|
||||||
|
if effect:
|
||||||
|
if not re.search(r"%s" % effect, torrent_info.title, re.I):
|
||||||
|
logger.info(f"{torrent_info.title} 不匹配特效规则 {effect}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|||||||
@@ -88,11 +88,13 @@ class SystemConfigKey(Enum):
|
|||||||
CustomFilterRules = "CustomFilterRules"
|
CustomFilterRules = "CustomFilterRules"
|
||||||
# 用户规则组
|
# 用户规则组
|
||||||
UserRuleGroups = "UserRuleGroups"
|
UserRuleGroups = "UserRuleGroups"
|
||||||
# 搜索默认过滤规则
|
# 搜索默认过滤规则组
|
||||||
SearchFilterRuleGroups = "SearchFilterRuleGroups"
|
SearchFilterRuleGroups = "SearchFilterRuleGroups"
|
||||||
# 订阅默认过滤规则
|
# 订阅默认过滤规则组
|
||||||
SubscribeFilterRuleGroups = "SubscribeFilterRuleGroups"
|
SubscribeFilterRuleGroups = "SubscribeFilterRuleGroups"
|
||||||
# 洗版默认过滤规则
|
# 订阅默认参数
|
||||||
|
SubscribeDefaultParams = "SubscribeDefaultParams"
|
||||||
|
# 洗版默认过滤规则组
|
||||||
BeseVersionFilterRuleGroups = "BeseVersionFilterRuleGroups"
|
BeseVersionFilterRuleGroups = "BeseVersionFilterRuleGroups"
|
||||||
# 订阅统计
|
# 订阅统计
|
||||||
SubscribeReport = "SubscribeReport"
|
SubscribeReport = "SubscribeReport"
|
||||||
|
|||||||
Reference in New Issue
Block a user