add 正在下载查询

This commit is contained in:
jxxghp
2023-06-15 18:10:04 +08:00
parent 237fe69d82
commit 84e4a4a527
9 changed files with 70 additions and 10 deletions

View File

@ -9,7 +9,7 @@ from app.helper.torrent import TorrentHelper
from app.log import logger
from app.schemas.context import ExistMediaInfo, NotExistMediaInfo
from app.utils.string import StringUtils
from app.utils.types import MediaType
from app.utils.types import MediaType, TorrentStatus
class DownloadChain(ChainBase):
@ -473,3 +473,20 @@ class DownloadChain(ChainBase):
return False, no_exists
# 全部存在
return True, no_exists
def get_downloading(self):
"""
查询正在下载的任务,并发送消息
"""
torrents = self.list_torrents(status=TorrentStatus.DOWNLOADING)
if not torrents:
self.post_message(title="没有正在下载的任务!")
return
# 发送消息
title = f"{len(torrents)} 个任务正在下载:"
messages = []
for torrent in torrents:
messages.append(f"{torrent.title} "
f"{StringUtils.str_filesize(torrent.size)} "
f"{round(torrent.progress) * 100}%")
self.post_message(title=title, text="\n".join(messages))