diff --git a/app/chain/search.py b/app/chain/search.py index 76802f8c..6ebc8496 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -10,7 +10,7 @@ from app.helper.sites import SitesHelper # noqa from fastapi.concurrency import run_in_threadpool from app.chain import ChainBase -from app.core.config import global_vars +from app.core.config import global_vars, settings from app.core.context import Context from app.core.context import MediaInfo, TorrentInfo from app.core.event import eventmanager, Event @@ -201,6 +201,10 @@ class SearchChain(ChainBase): mediainfo.hk_title, mediainfo.tw_title, mediainfo.sg_title] if k])) + # 限制搜索关键词数量 + if settings.MAX_SEARCH_NAME_LIMIT: + keywords = keywords[:settings.MAX_SEARCH_NAME_LIMIT] + return season_episodes, keywords def __parse_result(self, torrents: List[TorrentInfo], diff --git a/app/core/config.py b/app/core/config.py index 6f1525a0..2fd87bd2 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -211,6 +211,8 @@ class ConfigModel(BaseModel): LOCAL_EXISTS_SEARCH: bool = False # 搜索多个名称 SEARCH_MULTIPLE_NAME: bool = False + # 最大搜索名称数量 + MAX_SEARCH_NAME_LIMIT: int = 2 # 站点数据刷新间隔(小时) SITEDATA_REFRESH_INTERVAL: int = 6 # 读取和发送站点消息