mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix(api): 无法设置非默认下载器状态
This commit is contained in:
@@ -94,22 +94,22 @@ def add(
|
|||||||
|
|
||||||
@router.get("/start/{hashString}", summary="开始任务", response_model=schemas.Response)
|
@router.get("/start/{hashString}", summary="开始任务", response_model=schemas.Response)
|
||||||
def start(
|
def start(
|
||||||
hashString: str,
|
hashString: str, name: Optional[str] = None,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
开如下载任务
|
开如下载任务
|
||||||
"""
|
"""
|
||||||
ret = DownloadChain().set_downloading(hashString, "start")
|
ret = DownloadChain().set_downloading(hashString, "start", name=name)
|
||||||
return schemas.Response(success=True if ret else False)
|
return schemas.Response(success=True if ret else False)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/stop/{hashString}", summary="暂停任务", response_model=schemas.Response)
|
@router.get("/stop/{hashString}", summary="暂停任务", response_model=schemas.Response)
|
||||||
def stop(hashString: str,
|
def stop(hashString: str, name: Optional[str] = None,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
暂停下载任务
|
暂停下载任务
|
||||||
"""
|
"""
|
||||||
ret = DownloadChain().set_downloading(hashString, "stop")
|
ret = DownloadChain().set_downloading(hashString, "stop", name=name)
|
||||||
return schemas.Response(success=True if ret else False)
|
return schemas.Response(success=True if ret else False)
|
||||||
|
|
||||||
|
|
||||||
@@ -125,10 +125,10 @@ def clients(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
|||||||
|
|
||||||
|
|
||||||
@router.delete("/{hashString}", summary="删除下载任务", response_model=schemas.Response)
|
@router.delete("/{hashString}", summary="删除下载任务", response_model=schemas.Response)
|
||||||
def delete(hashString: str,
|
def delete(hashString: str, name: Optional[str] = None,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
删除下载任务
|
删除下载任务
|
||||||
"""
|
"""
|
||||||
ret = DownloadChain().remove_downloading(hashString)
|
ret = DownloadChain().remove_downloading(hashString, name=name)
|
||||||
return schemas.Response(success=True if ret else False)
|
return schemas.Response(success=True if ret else False)
|
||||||
|
|||||||
@@ -939,21 +939,21 @@ class DownloadChain(ChainBase):
|
|||||||
ret_torrents.append(torrent)
|
ret_torrents.append(torrent)
|
||||||
return ret_torrents
|
return ret_torrents
|
||||||
|
|
||||||
def set_downloading(self, hash_str, oper: str) -> bool:
|
def set_downloading(self, hash_str, oper: str, name: Optional[str] = None) -> bool:
|
||||||
"""
|
"""
|
||||||
控制下载任务 start/stop
|
控制下载任务 start/stop
|
||||||
"""
|
"""
|
||||||
if oper == "start":
|
if oper == "start":
|
||||||
return self.start_torrents(hashs=[hash_str])
|
return self.start_torrents(hashs=[hash_str], downloader=name)
|
||||||
elif oper == "stop":
|
elif oper == "stop":
|
||||||
return self.stop_torrents(hashs=[hash_str])
|
return self.stop_torrents(hashs=[hash_str], downloader=name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def remove_downloading(self, hash_str: str) -> bool:
|
def remove_downloading(self, hash_str: str, name: Optional[str] = None) -> bool:
|
||||||
"""
|
"""
|
||||||
删除下载任务
|
删除下载任务
|
||||||
"""
|
"""
|
||||||
return self.remove_torrents(hashs=[hash_str])
|
return self.remove_torrents(hashs=[hash_str], downloader=name)
|
||||||
|
|
||||||
@eventmanager.register(EventType.DownloadFileDeleted)
|
@eventmanager.register(EventType.DownloadFileDeleted)
|
||||||
def download_file_deleted(self, event: Event):
|
def download_file_deleted(self, event: Event):
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
server: Transmission = self.get_instance(downloader)
|
server: Transmission = self.get_instance(downloader)
|
||||||
if not server:
|
if not server:
|
||||||
return None
|
return None
|
||||||
return server.start_torrents(ids=hashs)
|
return server.stop_torrents(ids=hashs)
|
||||||
|
|
||||||
def torrent_files(self, tid: str, downloader: Optional[str] = None) -> Optional[List[File]]:
|
def torrent_files(self, tid: str, downloader: Optional[str] = None) -> Optional[List[File]]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class Transmission:
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
torrents, error = self.get_torrents(ids=ids,
|
torrents, error = self.get_torrents(ids=ids,
|
||||||
status=["downloading", "download_pending"],
|
status=["downloading", "download_pending", "stopped"],
|
||||||
tags=tags)
|
tags=tags)
|
||||||
return None if error else torrents or []
|
return None if error else torrents or []
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
Reference in New Issue
Block a user