From 5b0db854c408dc3c86a78f040c46b884968009e2 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 17 Oct 2026 05:24:05 +0800 Subject: [PATCH] fix(types): separate workflow search input and parsed parameters --- app/workflow/actions/fetch_torrents.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/workflow/actions/fetch_torrents.py b/app/workflow/actions/fetch_torrents.py index 9ff183f99..4202c3d56 100644 --- a/app/workflow/actions/fetch_torrents.py +++ b/app/workflow/actions/fetch_torrents.py @@ -38,7 +38,8 @@ class FetchTorrentsAction(BaseAction): "outputs": [{"name": "torrents", "label": "资源", "kind": "list"}], } - def __init__(self, action_id: str): + def __init__(self, action_id: str) -> None: + """为当前动作建立独立的搜索结果集合。""" super().__init__(action_id) self._torrents: list[WorkflowContext] = [] @@ -48,34 +49,35 @@ class FetchTorrentsAction(BaseAction): @property def success(self) -> bool: + """以动作完成状态报告执行结果。""" return self.done - def execute(self, workflow_id: int, params: dict, context: ActionContext) -> ActionContext: + def execute(self, workflow_id: int, params: dict[str, object], context: ActionContext) -> ActionContext: """ 搜索站点,获取资源列表 """ - params = FetchTorrentsParams(**params) + action_params = FetchTorrentsParams(**params) searchchain = SearchChain() - if params.search_type == "keyword": + if action_params.search_type == "keyword": # 按关键字搜索 torrents = searchchain.search_by_title( - title=params.name or "", - sites=params.sites, + title=action_params.name or "", + sites=action_params.sites, ) for torrent in torrents: if runtime_stop_state.is_workflow_stopped(workflow_id): break meta_info = torrent.meta_info - if params.year and (not meta_info or meta_info.year != params.year): + if action_params.year and (not meta_info or meta_info.year != action_params.year): continue - if params.type and torrent.media_info and torrent.media_info.type != MediaType(params.type): + if action_params.type and torrent.media_info and torrent.media_info.type != MediaType(action_params.type): continue - if params.season is not None and ( - not meta_info or meta_info.begin_season != params.season + if action_params.season is not None and ( + not meta_info or meta_info.begin_season != action_params.season ): continue # 识别媒体信息 - if params.match_media: + if action_params.match_media: if not meta_info: continue torrent.media_info = MediaChain().recognize_by_meta( @@ -98,7 +100,7 @@ class FetchTorrentsAction(BaseAction): media_source=media.media_source, media_id=media.media_id, mtype=MediaType(media.type), - sites=params.sites, + sites=action_params.sites, ) for torrent in torrents: self._torrents.append(self._to_workflow_context(torrent))