downloading api
This commit is contained in:
parent
96c7a3fc92
commit
5a5edfb2a3
@ -1,7 +1,7 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api.endpoints import login, user, site, message, webhook, subscribe, \
|
||||
media, douban, search, plugin, tmdb, history, system
|
||||
media, douban, search, plugin, tmdb, history, system, download
|
||||
|
||||
api_router = APIRouter()
|
||||
api_router.include_router(login.router, tags=["login"])
|
||||
@ -17,3 +17,4 @@ api_router.include_router(tmdb.router, prefix="/tmdb", tags=["tmdb"])
|
||||
api_router.include_router(history.router, prefix="/history", tags=["history"])
|
||||
api_router.include_router(system.router, prefix="/system", tags=["system"])
|
||||
api_router.include_router(plugin.router, prefix="/plugin", tags=["plugin"])
|
||||
api_router.include_router(download.router, prefix="/download", tags=["download"])
|
||||
|
18
app/api/endpoints/download.py
Normal file
18
app/api/endpoints/download.py
Normal file
@ -0,0 +1,18 @@
|
||||
from typing import Any, List
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app import schemas
|
||||
from app.chain.download import DownloadChain
|
||||
from app.core.security import verify_token
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/", summary="正在下载", response_model=List[schemas.DownloadingTorrent])
|
||||
async def read_subscribes(
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
查询正在下载的任务
|
||||
"""
|
||||
return DownloadChain().downloading()
|
@ -8,7 +8,7 @@ from app.core.meta import MetaBase
|
||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||
from app.helper.torrent import TorrentHelper
|
||||
from app.log import logger
|
||||
from app.schemas import ExistMediaInfo, NotExistMediaInfo
|
||||
from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent
|
||||
from app.schemas.types import MediaType, TorrentStatus, EventType
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
@ -530,3 +530,9 @@ class DownloadChain(ChainBase):
|
||||
f"{round(torrent.progress * 100, 1)}%")
|
||||
index += 1
|
||||
self.post_message(title=title, text="\n".join(messages), userid=userid)
|
||||
|
||||
def downloading(self) -> List[DownloadingTorrent]:
|
||||
"""
|
||||
查询正在下载的任务
|
||||
"""
|
||||
return self.list_torrents(status=TorrentStatus.DOWNLOADING) or []
|
||||
|
Loading…
x
Reference in New Issue
Block a user