fix download_hash补充逻辑

This commit is contained in:
thsrite
2023-08-21 13:18:42 +08:00
parent 7b0ba6112e
commit f387846732

View File

@ -345,22 +345,25 @@ class DirMonitor(_PluginBase):
for torrent in qb_torrents:
if str(torrent.get("name")) == str(torrent_name) \
or str(torrent.get("name")) == str(torrent_name2):
files = self.qb.get_files(tid=torrent.get("hash"))
if files:
for file in files:
torrent_file_name = file.get("name")
if str(file_name) == str(os.path.basename(torrent_file_name)):
return torrent.get("hash")
# 处理辅种器 遍历所有种子,按照添加升序升序,第一个种子是初始种子
mate_torrents = []
# 处理辅种器 遍历所有种子,按照添加时间升序
if len(tr_torrents) > 0:
tr_torrents = sorted(tr_torrents, key=lambda x: x.added_date)
for torrent in tr_torrents:
if str(torrent.get("name")) == str(torrent_name) \
or str(torrent.get("name")) == str(torrent_name2):
mate_torrents.append(torrent)
# 匹配上则按照时间升序
if mate_torrents:
if len(mate_torrents) > 1:
mate_torrents = sorted(mate_torrents, key=lambda x: x.added_date)
# 最早添加的hash是下载的hash
return mate_torrents[0].get("hashString")
files = self.tr.get_files(tid=torrent.get("hashString"))
if files:
for file in files:
torrent_file_name = file.name
if str(file_name) == str(os.path.basename(torrent_file_name)):
return torrent.get("hashString")
return None
def get_state(self) -> bool: