diff --git a/app/chain/download.py b/app/chain/download.py index 78d8e9f6..a5e9bdce 100644 --- a/app/chain/download.py +++ b/app/chain/download.py @@ -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 diff --git a/app/schemas/context.py b/app/schemas/context.py index c1ec23fc..fe5188bc 100644 --- a/app/schemas/context.py +++ b/app/schemas/context.py @@ -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):