fix actions execute

This commit is contained in:
jxxghp
2025-02-27 20:39:42 +08:00
parent 37926b4c19
commit f8ed16666c
15 changed files with 61 additions and 31 deletions
+2 -1
View File
@@ -45,10 +45,11 @@ class AddDownloadAction(BaseAction):
def success(self) -> bool:
return True if self._added_downloads else False
async def execute(self, params: AddDownloadParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
将上下文中的torrents添加到下载任务中
"""
params = AddDownloadParams(**params)
for t in context.torrents:
if not t.meta_info:
t.meta_info = MetaInfo(title=t.title, subtitle=t.description)
+1 -1
View File
@@ -41,7 +41,7 @@ class AddSubscribeAction(BaseAction):
def success(self) -> bool:
return True if self._added_subscribes else False
async def execute(self, params: AddSubscribeParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
将medias中的信息添加订阅,如果订阅不存在的话
"""
+1 -1
View File
@@ -39,7 +39,7 @@ class FetchDownloadsAction(BaseAction):
return True
return True if all([d.completed for d in self._downloads]) else False
async def execute(self, params: FetchDownloadsParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
更新downloads中的下载任务状态
"""
+2 -1
View File
@@ -117,10 +117,11 @@ class FetchMediasAction(BaseAction):
return s
return None
async def execute(self, params: FetchMediasParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
获取媒体数据,填充到medias
"""
params = FetchMediasParams(**params)
for name in params.sources:
source = self.__get_source(name)
if not source:
+2 -1
View File
@@ -51,10 +51,11 @@ class FetchRssAction(BaseAction):
def success(self) -> bool:
return True if self._rss_torrents else False
async def execute(self, params: FetchRssParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
请求RSS地址获取数据,并解析为资源列表
"""
params = FetchRssParams(**params)
if not params.url:
return context
+3 -2
View File
@@ -13,7 +13,7 @@ class FetchTorrentsParams(ActionParams):
获取站点资源参数
"""
name: str = Field(None, description="资源名称")
year: Optional[int] = Field(None, description="年份")
year: Optional[str] = Field(None, description="年份")
type: Optional[str] = Field(None, description="资源类型 (电影/电视剧)")
season: Optional[int] = Field(None, description="季度")
sites: Optional[List[int]] = Field([], description="站点列表")
@@ -46,10 +46,11 @@ class FetchTorrentsAction(BaseAction):
def success(self) -> bool:
return True if self._torrents else False
async def execute(self, params: FetchTorrentsParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
搜索站点,获取资源列表
"""
params = FetchTorrentsParams(**params)
torrents = self.searchchain.search_by_title(title=params.name, sites=params.sites)
for torrent in torrents:
if params.year and torrent.meta_info.year != params.year:
+2 -1
View File
@@ -40,10 +40,11 @@ class FilterMediasAction(BaseAction):
def success(self) -> bool:
return True if self.__medias else False
async def execute(self, params: FilterMediasParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
过滤medias中媒体数据
"""
params = FilterMediasParams(**params)
for media in context.medias:
if params.type and media.type != MediaType(params.type):
continue
+2 -1
View File
@@ -48,10 +48,11 @@ class FilterTorrentsAction(BaseAction):
def success(self) -> bool:
return self.done
async def execute(self, params: FilterTorrentsParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
过滤torrents中的资源
"""
params = FilterTorrentsParams(**params)
for torrent in context.torrents:
if self.torrenthelper.filter_torrent(
torrent_info=torrent.torrent_info,
+1 -1
View File
@@ -43,7 +43,7 @@ class ScrapeFileAction(BaseAction):
def success(self) -> bool:
return True if self.__scraped_files else False
async def execute(self, params: ScrapeFileParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
刮削fileitems中的所有文件
"""
+1 -1
View File
@@ -33,7 +33,7 @@ class SendEventAction(BaseAction):
def success(self) -> bool:
return self.done
async def execute(self, params: SendEventParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
发送events中的事件
"""
+1 -1
View File
@@ -40,7 +40,7 @@ class SendMessageAction(BaseAction):
def success(self) -> bool:
return self.done
async def execute(self, params: SendMessageParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
发送messages中的消息
"""
+1 -1
View File
@@ -42,7 +42,7 @@ class TransferFileAction(BaseAction):
def success(self) -> bool:
return True if self.__fileitems else False
async def execute(self, params: TransferFileParams, context: ActionContext) -> ActionContext:
def execute(self, params: dict, context: ActionContext) -> ActionContext:
"""
从downloads中整理文件,记录到fileitems
"""