mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-09 06:22:29 +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}"
|
||||
|
||||
Reference in New Issue
Block a user