下载控制
This commit is contained in:
@ -253,6 +253,22 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
||||
"""
|
||||
return self.run_module("remove_torrents", hashs=hashs)
|
||||
|
||||
def start_torrents(self, hashs: Union[list, str]) -> bool:
|
||||
"""
|
||||
开始下载
|
||||
:param hashs: 种子Hash
|
||||
:return: bool
|
||||
"""
|
||||
return self.run_module("start_torrent", hash_str=hashs)
|
||||
|
||||
def stop_torrents(self, hashs: Union[list, str]) -> bool:
|
||||
"""
|
||||
停止下载
|
||||
:param hashs: 种子Hash
|
||||
:return: bool
|
||||
"""
|
||||
return self.run_module("stop_torrent", hashs=hashs)
|
||||
|
||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[ExistMediaInfo]:
|
||||
"""
|
||||
判断媒体文件是否存在
|
||||
|
@ -552,3 +552,19 @@ class DownloadChain(ChainBase):
|
||||
}
|
||||
ret_torrents.append(torrent)
|
||||
return ret_torrents
|
||||
|
||||
def set_downloading(self, hash_str, oper: str) -> bool:
|
||||
"""
|
||||
控制下载任务 start/pause
|
||||
"""
|
||||
if oper == "start":
|
||||
return self.start_torrents(hashs=[hash_str])
|
||||
elif oper == "pause":
|
||||
return self.stop_torrents(hashs=[hash_str])
|
||||
return False
|
||||
|
||||
def remove_downloading(self, hash_str: str) -> bool:
|
||||
"""
|
||||
删除下载任务
|
||||
"""
|
||||
return self.remove_torrents(hashs=[hash_str])
|
||||
|
Reference in New Issue
Block a user