fix tag bug
This commit is contained in:
parent
6b3bfd04a3
commit
c1a22518a2
@ -51,7 +51,7 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
return None, f"添加种子任务失败:{torrent_path}"
|
return None, f"添加种子任务失败:{torrent_path}"
|
||||||
else:
|
else:
|
||||||
# 获取种子Hash
|
# 获取种子Hash
|
||||||
torrent_hash = self.qbittorrent.get_torrent_id_by_tag(tag=tag)
|
torrent_hash = self.qbittorrent.get_torrent_id_by_tag(tags=tag)
|
||||||
if not torrent_hash:
|
if not torrent_hash:
|
||||||
return None, f"获取种子Hash失败:{torrent_path}"
|
return None, f"获取种子Hash失败:{torrent_path}"
|
||||||
else:
|
else:
|
||||||
@ -149,4 +149,3 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
:return: bool
|
:return: bool
|
||||||
"""
|
"""
|
||||||
return self.qbittorrent.delete_torrents(delete_file=True, ids=hashs)
|
return self.qbittorrent.delete_torrents(delete_file=True, ids=hashs)
|
||||||
|
|
||||||
|
@ -66,7 +66,8 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
if not isinstance(tags, list):
|
if not isinstance(tags, list):
|
||||||
tags = [tags]
|
tags = [tags]
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
if set(tags).issubset(set(torrent.get("tags").split(','))):
|
torrent_tags = [str(tag).strip() for tag in torrent.get("tags").split(',')]
|
||||||
|
if set(tags).issubset(set(torrent_tags)):
|
||||||
results.append(torrent)
|
results.append(torrent)
|
||||||
return results, False
|
return results, False
|
||||||
return torrents or [], False
|
return torrents or [], False
|
||||||
@ -132,14 +133,14 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"设置强制作种出错:{err}")
|
logger.error(f"设置强制作种出错:{err}")
|
||||||
|
|
||||||
def __get_last_add_torrentid_by_tag(self, tag: Union[str, list],
|
def __get_last_add_torrentid_by_tag(self, tags: Union[str, list],
|
||||||
status: Union[str, list] = None) -> Optional[str]:
|
status: Union[str, list] = None) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
根据种子的下载链接获取下载中或暂停的钟子的ID
|
根据种子的下载链接获取下载中或暂停的钟子的ID
|
||||||
:return: 种子ID
|
:return: 种子ID
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
torrents, _ = self.get_torrents(status=status, tags=tag)
|
torrents, _ = self.get_torrents(status=status, tags=tags)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"获取种子列表出错:{err}")
|
logger.error(f"获取种子列表出错:{err}")
|
||||||
return None
|
return None
|
||||||
@ -148,21 +149,21 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_torrent_id_by_tag(self, tag: Union[str, list],
|
def get_torrent_id_by_tag(self, tags: Union[str, list],
|
||||||
status: Union[str, list] = None) -> Optional[str]:
|
status: Union[str, list] = None) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
通过标签多次尝试获取刚添加的种子ID,并移除标签
|
通过标签多次尝试获取刚添加的种子ID,并移除标签
|
||||||
"""
|
"""
|
||||||
torrent_id = None
|
torrent_id = None
|
||||||
# QB添加下载后需要时间,重试5次每次等待5秒
|
# QB添加下载后需要时间,重试5次每次等待5秒
|
||||||
for i in range(1, 6):
|
for i in range(1, 10):
|
||||||
time.sleep(5)
|
time.sleep(3)
|
||||||
torrent_id = self.__get_last_add_torrentid_by_tag(tag=tag,
|
torrent_id = self.__get_last_add_torrentid_by_tag(tags=tags,
|
||||||
status=status)
|
status=status)
|
||||||
if torrent_id is None:
|
if torrent_id is None:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.remove_torrents_tag(torrent_id, tag)
|
self.remove_torrents_tag(torrent_id, tags)
|
||||||
break
|
break
|
||||||
return torrent_id
|
return torrent_id
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ class Transmission(metaclass=Singleton):
|
|||||||
if status and torrent.status not in status:
|
if status and torrent.status not in status:
|
||||||
continue
|
continue
|
||||||
# 种子标签
|
# 种子标签
|
||||||
labels = torrent.labels.split(',') if hasattr(torrent, "labels") else []
|
labels = [str(tag).strip()
|
||||||
|
for tag in torrent.labels.split(',')] if hasattr(torrent, "labels") else []
|
||||||
if tags and not set(tags).issubset(set(labels)):
|
if tags and not set(tags).issubset(set(labels)):
|
||||||
continue
|
continue
|
||||||
ret_torrents.append(torrent)
|
ret_torrents.append(torrent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user