mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-14 02:00:31 +08:00
fix actions
This commit is contained in:
@@ -90,8 +90,8 @@ class FetchTorrentsAction(BaseAction):
|
||||
for torrent in torrents:
|
||||
self._torrents.append(torrent)
|
||||
|
||||
# 随机休眠 10-60秒
|
||||
sleep_time = random.randint(10, 60)
|
||||
# 随机休眠 5-30秒
|
||||
sleep_time = random.randint(5, 30)
|
||||
logger.info(f"随机休眠 {sleep_time} 秒 ...")
|
||||
time.sleep(sleep_time)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from pydantic import Field
|
||||
|
||||
from app.actions import BaseAction
|
||||
from app.core.config import global_vars
|
||||
from app.log import logger
|
||||
from app.schemas import ActionParams, ActionContext
|
||||
|
||||
|
||||
@@ -12,7 +13,6 @@ class FilterMediasParams(ActionParams):
|
||||
过滤媒体数据参数
|
||||
"""
|
||||
type: Optional[str] = Field(None, description="媒体类型 (电影/电视剧)")
|
||||
category: Optional[str] = Field(None, description="媒体类别 (二级分类)")
|
||||
vote: Optional[int] = Field(0, description="评分")
|
||||
year: Optional[str] = Field(None, description="年份")
|
||||
|
||||
@@ -53,16 +53,15 @@ class FilterMediasAction(BaseAction):
|
||||
break
|
||||
if params.type and media.type != params.type:
|
||||
continue
|
||||
if params.category and media.category != params.category:
|
||||
continue
|
||||
if params.vote and media.vote_average < params.vote:
|
||||
continue
|
||||
if params.year and media.year != params.year:
|
||||
continue
|
||||
self._medias.append(media)
|
||||
|
||||
if self._medias:
|
||||
context.medias = self._medias
|
||||
logger.info(f"过滤后剩余 {len(self._medias)} 条媒体数据")
|
||||
|
||||
context.medias = self._medias
|
||||
|
||||
self.job_done(f"过滤后剩余 {len(self._medias)} 条媒体数据")
|
||||
return context
|
||||
|
||||
@@ -5,6 +5,7 @@ from pydantic import Field
|
||||
from app.actions import BaseAction, ActionChain
|
||||
from app.core.config import global_vars
|
||||
from app.helper.torrent import TorrentHelper
|
||||
from app.log import logger
|
||||
from app.schemas import ActionParams, ActionContext
|
||||
|
||||
|
||||
@@ -78,6 +79,8 @@ class FilterTorrentsAction(BaseAction):
|
||||
):
|
||||
self._torrents.append(torrent)
|
||||
|
||||
logger.info(f"过滤后剩余 {len(self._torrents)} 个资源")
|
||||
|
||||
context.torrents = self._torrents
|
||||
|
||||
self.job_done(f"过滤后剩余 {len(self._torrents)} 个资源")
|
||||
|
||||
@@ -47,10 +47,10 @@ class SendMessageAction(BaseAction):
|
||||
发送messages中的消息
|
||||
"""
|
||||
params = SendMessageParams(**params)
|
||||
msg_text = f"当前进度:{context.__progress__}%"
|
||||
msg_text = f"当前进度:{context.progress}%"
|
||||
index = 1
|
||||
if context.__execute_history__:
|
||||
for history in context.__execute_history__:
|
||||
if context.execute_history:
|
||||
for history in context.execute_history:
|
||||
if not history.message:
|
||||
continue
|
||||
msg_text += f"\n{index}. {history.action}:{history.message}"
|
||||
|
||||
@@ -91,7 +91,7 @@ class WorkflowExecutor:
|
||||
if not self.success:
|
||||
break
|
||||
if not self.queue:
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
continue
|
||||
# 取出队首节点
|
||||
node_id = self.queue.popleft()
|
||||
@@ -135,10 +135,10 @@ class WorkflowExecutor:
|
||||
try:
|
||||
self.finished_actions += 1
|
||||
# 更新当前进度
|
||||
self.context.__progress__ = round(self.finished_actions / self.total_actions) * 100
|
||||
self.context.progress = round(self.finished_actions / self.total_actions) * 100
|
||||
|
||||
# 补充执行历史
|
||||
self.context.__execute_history__.append(
|
||||
self.context.execute_history.append(
|
||||
ActionExecution(
|
||||
action=action.name,
|
||||
result=state,
|
||||
|
||||
@@ -70,8 +70,8 @@ class ActionContext(BaseModel):
|
||||
downloads: Optional[List[DownloadTask]] = Field([], description="下载任务列表")
|
||||
sites: Optional[List[Site]] = Field([], description="站点列表")
|
||||
subscribes: Optional[List[Subscribe]] = Field([], description="订阅列表")
|
||||
__execute_history__: Optional[List[ActionExecution]] = Field([], description="执行历史")
|
||||
__progress__: Optional[int] = Field(0, description="执行进度(%)")
|
||||
execute_history: Optional[List[ActionExecution]] = Field([], description="执行历史")
|
||||
progress: Optional[int] = Field(0, description="执行进度(%)")
|
||||
|
||||
|
||||
class ActionFlow(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user