修复tr 选中种子下载失败

This commit is contained in:
tonser
2024-02-29 02:09:53 +08:00
parent c9ebe76eb1
commit 31ca41828e
2 changed files with 19 additions and 0 deletions

View File

@ -121,20 +121,25 @@ class TransmissionModule(_ModuleBase):
return torrent_hash, "获取种子文件失败,下载任务可能在暂停状态"
# 需要的文件信息
file_ids = []
unwanted_file_ids = []
for torrent_file in torrent_files:
file_id = torrent_file.id
file_name = torrent_file.name
meta_info = MetaInfo(file_name)
if not meta_info.episode_list:
unwanted_file_ids.append(file_id)
continue
selected = set(meta_info.episode_list).issubset(set(episodes))
if not selected:
unwanted_file_ids.append(file_id)
continue
file_ids.append(file_id)
# 选择文件
self.transmission.set_files(torrent_hash, file_ids)
self.transmission.set_unwanted_files(torrent_hash, unwanted_file_ids)
# 开始任务
self.transmission.start_torrents(torrent_hash)
return torrent_hash, "添加下载任务成功"
else:
return torrent_hash, "添加下载任务成功"

View File

@ -242,6 +242,19 @@ class Transmission:
logger.error(f"设置下载文件状态出错:{str(err)}")
return False
def set_unwanted_files(self, tid: str, file_ids: list) -> bool:
"""
设置下载文件的状态
"""
if not self.trc:
return False
try:
self.trc.change_torrent(ids=tid, files_unwanted=file_ids)
return True
except Exception as err:
logger.error(f"设置下载文件状态出错:{str(err)}")
return False
def transfer_info(self) -> Optional[SessionStats]:
"""
获取传输信息
@ -359,3 +372,4 @@ class Transmission:
except Exception as err:
logger.error(f"修改tracker出错{str(err)}")
return False