fix QB&TR 判重
This commit is contained in:
@ -49,7 +49,7 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
:return: 种子Hash,错误信息
|
:return: 种子Hash,错误信息
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __get_torrent_name():
|
def __get_torrent_info() -> Tuple[str, int]:
|
||||||
"""
|
"""
|
||||||
获取种子名称
|
获取种子名称
|
||||||
"""
|
"""
|
||||||
@ -58,10 +58,10 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
torrentinfo = Torrent.from_file(content)
|
torrentinfo = Torrent.from_file(content)
|
||||||
else:
|
else:
|
||||||
torrentinfo = Torrent.from_string(content)
|
torrentinfo = Torrent.from_string(content)
|
||||||
return torrentinfo.name
|
return torrentinfo.name, torrentinfo.total_size
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"获取种子名称失败:{e}")
|
logger.error(f"获取种子名称失败:{e}")
|
||||||
return ""
|
return "", 0
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
@ -87,7 +87,7 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
)
|
)
|
||||||
if not state:
|
if not state:
|
||||||
# 读取种子的名称
|
# 读取种子的名称
|
||||||
torrent_name = __get_torrent_name()
|
torrent_name, torrent_size = __get_torrent_info()
|
||||||
if not torrent_name:
|
if not torrent_name:
|
||||||
return None, f"添加种子任务失败:无法读取种子文件"
|
return None, f"添加种子任务失败:无法读取种子文件"
|
||||||
# 查询所有下载器的种子
|
# 查询所有下载器的种子
|
||||||
@ -96,7 +96,8 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
return None, "无法连接qbittorrent下载器"
|
return None, "无法连接qbittorrent下载器"
|
||||||
if torrents:
|
if torrents:
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
if torrent.get("name") == torrent_name:
|
# 名称与大小相等则认为是同一个种子
|
||||||
|
if torrent.get("name") == torrent_name and torrent.get("total_size") == torrent_size:
|
||||||
torrent_hash = torrent.get("hash")
|
torrent_hash = torrent.get("hash")
|
||||||
torrent_tags = [str(tag).strip() for tag in torrent.get("tags").split(',')]
|
torrent_tags = [str(tag).strip() for tag in torrent.get("tags").split(',')]
|
||||||
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.get('name')}")
|
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.get('name')}")
|
||||||
|
@ -49,7 +49,7 @@ class TransmissionModule(_ModuleBase):
|
|||||||
:return: 种子Hash
|
:return: 种子Hash
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __get_torrent_name():
|
def __get_torrent_info() -> Tuple[str, int]:
|
||||||
"""
|
"""
|
||||||
获取种子名称
|
获取种子名称
|
||||||
"""
|
"""
|
||||||
@ -58,10 +58,10 @@ class TransmissionModule(_ModuleBase):
|
|||||||
torrentinfo = Torrent.from_file(content)
|
torrentinfo = Torrent.from_file(content)
|
||||||
else:
|
else:
|
||||||
torrentinfo = Torrent.from_string(content)
|
torrentinfo = Torrent.from_string(content)
|
||||||
return torrentinfo.name
|
return torrentinfo.name, torrentinfo.total_size
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"获取种子名称失败:{e}")
|
logger.error(f"获取种子名称失败:{e}")
|
||||||
return ""
|
return "", 0
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
@ -85,7 +85,7 @@ class TransmissionModule(_ModuleBase):
|
|||||||
)
|
)
|
||||||
if not torrent:
|
if not torrent:
|
||||||
# 读取种子的名称
|
# 读取种子的名称
|
||||||
torrent_name = __get_torrent_name()
|
torrent_name, torrent_size = __get_torrent_info()
|
||||||
if not torrent_name:
|
if not torrent_name:
|
||||||
return None, f"添加种子任务失败:无法读取种子文件"
|
return None, f"添加种子任务失败:无法读取种子文件"
|
||||||
# 查询所有下载器的种子
|
# 查询所有下载器的种子
|
||||||
@ -94,7 +94,8 @@ class TransmissionModule(_ModuleBase):
|
|||||||
return None, "无法连接transmission下载器"
|
return None, "无法连接transmission下载器"
|
||||||
if torrents:
|
if torrents:
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
if torrent.name == torrent_name:
|
# 名称与大小相等则认为是同一个种子
|
||||||
|
if torrent.name == torrent_name and torrent.total_size == torrent_size:
|
||||||
torrent_hash = torrent.hashString
|
torrent_hash = torrent.hashString
|
||||||
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.name}")
|
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.name}")
|
||||||
# 给种子打上标签
|
# 给种子打上标签
|
||||||
|
Reference in New Issue
Block a user