This commit is contained in:
jxxghp
2023-06-07 20:03:53 +08:00
parent a1d65b7c87
commit 061c16c659
14 changed files with 91 additions and 53 deletions

View File

@@ -28,10 +28,16 @@ class TransmissionModule(_ModuleBase):
"""
# 如果要选择文件则先暂停
is_paused = True if episodes else False
# 标签
if settings.TORRENT_TAG:
labels = [settings.TORRENT_TAG]
else:
labels = None
# 添加任务
torrent = self.transmission.add_torrent(content=torrent_path.read_bytes(),
download_dir=settings.DOWNLOAD_PATH,
is_paused=is_paused,
labels=labels,
cookie=cookie)
if not torrent:
return None, f"添加种子任务失败:{torrent_path}"
@@ -70,16 +76,22 @@ class TransmissionModule(_ModuleBase):
else:
return torrent_hash, "添加下载任务成功"
def transfer_completed(self, hashs: Union[str, list]) -> bool:
"""
转移完成后的处理
:param hashs: 种子Hash
:return: 处理状态
"""
return self.transmission.set_torrent_tag(ids=hashs, tag=['已整理'])
def list_torrents(self, status: TorrentStatus) -> Optional[List[dict]]:
"""
获取下载器种子列表
:param status: 种子状态
:return: 下载器中符合状态的种子列表
"""
if status == TorrentStatus.COMPLETE:
torrents = self.transmission.get_completed_torrents()
elif status == TorrentStatus.DOWNLOADING:
torrents = self.transmission.get_completed_torrents()
if status == TorrentStatus.TRANSFER:
torrents = self.transmission.get_transfer_torrents(tag=settings.TORRENT_TAG)
else:
return None
return torrents