mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix actions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from app.actions import BaseAction
|
||||
from app.chain.download import DownloadChain
|
||||
from app.schemas import ActionParams, ActionContext
|
||||
|
||||
|
||||
@@ -14,6 +15,12 @@ class FetchDownloadsAction(BaseAction):
|
||||
获取下载任务
|
||||
"""
|
||||
|
||||
_downloads = []
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.downloadchain = DownloadChain()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "获取下载任务"
|
||||
@@ -24,7 +31,23 @@ class FetchDownloadsAction(BaseAction):
|
||||
|
||||
@property
|
||||
def success(self) -> bool:
|
||||
return True
|
||||
if not self._downloads:
|
||||
return True
|
||||
return True if all([d.completed for d in self._downloads]) else False
|
||||
|
||||
async def execute(self, params: FetchDownloadsParams, context: ActionContext) -> ActionContext:
|
||||
pass
|
||||
"""
|
||||
更新downloads中的下载任务状态
|
||||
"""
|
||||
self._downloads = context.downloads
|
||||
for download in self._downloads:
|
||||
torrents = self.downloadchain.list_torrents(hashs=[download.download_id])
|
||||
if not torrents:
|
||||
download.completed = True
|
||||
continue
|
||||
for t in torrents:
|
||||
if t.progress >= 100:
|
||||
download.completed = True
|
||||
|
||||
self.job_done()
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user