[O] Remove opposite tag if exists

This commit is contained in:
2026-03-09 02:51:31 -04:00
parent 1d9c33ab06
commit 9ece2ecf40
2 changed files with 21 additions and 1 deletions
+16
View File
@@ -140,3 +140,19 @@ def rename_torrent_and_folder(qb_client: Client, torrent_hash: str, new_name: st
time.sleep(1)
print("Warning: Rename may not have fully propagated yet.")
def remove_tag_if_exists(qb_client: Client, torrent_hash: str, tag_to_remove: str) -> None:
"""
Checks if a tag exists on a torrent, and removes it if it does.
"""
info = qb_client.torrents_info(hashes=torrent_hash)
if not info:
return
t_info = info[0]
tags = getattr(t_info, "tags", "")
if tags:
tag_list = [t.strip() for t in tags.split(",") if t.strip()]
if tag_to_remove in tag_list:
print(f"Removing existing tag '{tag_to_remove}' from torrent.")
qb_client.torrents_remove_tags(tags=tag_to_remove, torrent_hashes=torrent_hash)