Adds new script to remove cross-seed tag

This commit is contained in:
bobokun 2024-10-13 15:12:35 -04:00
parent 6af7ccac64
commit f19a0c149c
No known key found for this signature in database
GPG key ID: B73932169607D927
2 changed files with 54 additions and 1 deletions

View file

@ -1 +1 @@
4.1.12-develop1
4.1.12-develop2

View file

@ -0,0 +1,53 @@
#!/usr/bin/env python3
import os
# USES ENVIRONMENTAL VARIABLES, IF NONE ARE PRESENT WILL FALLBACK TO THE SECOND STRING
QBIT_HOST = os.getenv("QBT_HOST", "http://localhost:8080")
QBIT_USERNAME = os.getenv("QBT_USERNAME", "admin")
QBIT_PASSWORD = os.getenv("QBT_PASSWORD", "YOURPASSWORD")
CRED = "\033[91m"
CGREEN = "\33[32m"
CEND = "\033[0m"
CROSS_SEED_TAG = "cross-seed"
def split(separator, data):
if data is None:
return None
else:
return [item.strip() for item in str(data).split(separator)]
try:
from qbittorrentapi import APIConnectionError
from qbittorrentapi import Client
from qbittorrentapi import LoginFailed
except ModuleNotFoundError:
print('Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
exit(1)
try:
qbt_client = Client(host=QBIT_HOST, username=QBIT_USERNAME, password=QBIT_PASSWORD)
except LoginFailed:
raise "Qbittorrent Error: Failed to login. Invalid username/password."
except APIConnectionError:
raise "Qbittorrent Error: Unable to connect to the client."
except Exception:
raise "Qbittorrent Error: Unable to connect to the client."
print("qBittorrent:", qbt_client.app_version())
print("qBittorrent Web API:", qbt_client.app_web_api_version())
print()
torrents_list = qbt_client.torrents.info(sort="added_on", reverse=True)
print("Total torrents:", len(torrents_list))
print()
for torrent in torrents_list:
torrent_tags = split(",", torrent.tags)
if CROSS_SEED_TAG in torrent_tags:
print(CGREEN, "remove cross-seed tag:", torrent.name, CEND)
torrent.remove_tags(tags=CROSS_SEED_TAG)