downloading api

This commit is contained in:
jxxghp 2023-07-02 16:11:25 +08:00
parent 5a5edfb2a3
commit ca7542f90f
2 changed files with 18 additions and 1 deletions

View File

@ -535,4 +535,20 @@ class DownloadChain(ChainBase):
"""
查询正在下载的任务
"""
return self.list_torrents(status=TorrentStatus.DOWNLOADING) or []
torrents = self.list_torrents(status=TorrentStatus.DOWNLOADING)
if not torrents:
return []
ret_torrents = []
for torrent in torrents:
history = self.downloadhis.get_by_hash(torrent.hash)
if history:
torrent.media = {
"tmdbid": history.tmdbid,
"type": history.type,
"title": history.title,
"season": history.seasons,
"episode": history.episodes,
"image": history.image,
}
ret_torrents.append(torrent)
return ret_torrents

View File

@ -178,6 +178,7 @@ class TransferTorrent(BaseModel):
path: Optional[Path] = None
hash: Optional[str] = None
tags: Optional[str] = None
media: Optional[dict] = {}
class DownloadingTorrent(BaseModel):