mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
fix(qbittorrent): 修复种子文件读取和重复检查问题
- 将变量名从 torrent 改为 torrent_from_file 以避免混淆 - 修复添加种子任务失败时的错误检查逻辑 - 使用 getattr 函数安全获取种子文件的名称和大小属性 - 修复已存在种子任务检查时的属性访问问题 fix(transmission): 修复种子添加和重复检查逻辑 - 将变量名从 torrent 改为 torrent_from_file 以避免混淆 - 修复添加任务后的返回值变量名 - 使用 getattr 函数安全获取种子文件的名称和大小属性 - 修复已存在种子任务检查时的属性访问问题 - 修正种子哈希获取的变量引用
This commit is contained in:
@@ -124,12 +124,12 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase[Qbittorrent]):
|
|||||||
return None, None, None, "下载内容为空"
|
return None, None, None, "下载内容为空"
|
||||||
|
|
||||||
# 读取种子的名称
|
# 读取种子的名称
|
||||||
torrent, content = __get_torrent_info()
|
torrent_from_file, content = __get_torrent_info()
|
||||||
# 检查是否为磁力链接
|
# 检查是否为磁力链接
|
||||||
is_magnet = isinstance(content, str) and content.startswith("magnet:") or isinstance(content,
|
is_magnet = isinstance(content, str) and content.startswith("magnet:") or isinstance(content,
|
||||||
bytes) and content.startswith(
|
bytes) and content.startswith(
|
||||||
b"magnet:")
|
b"magnet:")
|
||||||
if not torrent and not is_magnet:
|
if not torrent_from_file and not is_magnet:
|
||||||
return None, None, None, f"添加种子任务失败:无法读取种子文件"
|
return None, None, None, f"添加种子任务失败:无法读取种子文件"
|
||||||
|
|
||||||
# 获取下载器
|
# 获取下载器
|
||||||
@@ -170,8 +170,8 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase[Qbittorrent]):
|
|||||||
try:
|
try:
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
# 名称与大小相等则认为是同一个种子
|
# 名称与大小相等则认为是同一个种子
|
||||||
if torrent.get("name") == torrent.name \
|
if torrent.get("name") == getattr(torrent_from_file, 'name', '') \
|
||||||
and torrent.get("total_size") == torrent.total_size:
|
and torrent.get("total_size") == getattr(torrent_from_file, 'total_size', 0):
|
||||||
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')}")
|
||||||
|
|||||||
@@ -125,12 +125,12 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
return None, None, None, "下载内容为空"
|
return None, None, None, "下载内容为空"
|
||||||
|
|
||||||
# 读取种子的名称
|
# 读取种子的名称
|
||||||
torrent, content = __get_torrent_info()
|
torrent_from_file, content = __get_torrent_info()
|
||||||
# 检查是否为磁力链接
|
# 检查是否为磁力链接
|
||||||
is_magnet = isinstance(content, str) and content.startswith("magnet:") or isinstance(content,
|
is_magnet = isinstance(content, str) and content.startswith("magnet:") or isinstance(content,
|
||||||
bytes) and content.startswith(
|
bytes) and content.startswith(
|
||||||
b"magnet:")
|
b"magnet:")
|
||||||
if not torrent and not is_magnet:
|
if not torrent_from_file and not is_magnet:
|
||||||
return None, None, None, f"添加种子任务失败:无法读取种子文件"
|
return None, None, None, f"添加种子任务失败:无法读取种子文件"
|
||||||
|
|
||||||
# 获取下载器
|
# 获取下载器
|
||||||
@@ -149,7 +149,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
else:
|
else:
|
||||||
labels = None
|
labels = None
|
||||||
# 添加任务
|
# 添加任务
|
||||||
torrent = server.add_torrent(
|
added_torrent = server.add_torrent(
|
||||||
content=content,
|
content=content,
|
||||||
download_dir=download_dir.as_posix(),
|
download_dir=download_dir.as_posix(),
|
||||||
is_paused=is_paused,
|
is_paused=is_paused,
|
||||||
@@ -159,7 +159,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
# TR 始终使用原始种子布局, 返回"Original"
|
# TR 始终使用原始种子布局, 返回"Original"
|
||||||
torrent_layout = "Original"
|
torrent_layout = "Original"
|
||||||
|
|
||||||
if not torrent:
|
if not added_torrent:
|
||||||
# 查询所有下载器的种子
|
# 查询所有下载器的种子
|
||||||
torrents, error = server.get_torrents()
|
torrents, error = server.get_torrents()
|
||||||
if error:
|
if error:
|
||||||
@@ -168,7 +168,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
try:
|
try:
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
# 名称与大小相等则认为是同一个种子
|
# 名称与大小相等则认为是同一个种子
|
||||||
if torrent.name == torrent.name and torrent.total_size == torrent.total_size:
|
if torrent.name == getattr(torrent_from_file, 'name', '') and torrent.total_size == getattr(torrent_from_file, 'total_size', 0):
|
||||||
torrent_hash = torrent.hashString
|
torrent_hash = torrent.hashString
|
||||||
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.name}")
|
logger.warn(f"下载器中已存在该种子任务:{torrent_hash} - {torrent.name}")
|
||||||
# 给种子打上标签
|
# 给种子打上标签
|
||||||
@@ -189,7 +189,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
|||||||
del torrents
|
del torrents
|
||||||
return None, None, None, f"添加种子任务失败:{content}"
|
return None, None, None, f"添加种子任务失败:{content}"
|
||||||
else:
|
else:
|
||||||
torrent_hash = torrent.hashString
|
torrent_hash = added_torrent.hashString
|
||||||
if is_paused:
|
if is_paused:
|
||||||
# 选择文件
|
# 选择文件
|
||||||
torrent_files = server.get_files(torrent_hash)
|
torrent_files = server.get_files(torrent_hash)
|
||||||
|
|||||||
Reference in New Issue
Block a user