diff --git a/VERSION b/VERSION index 67d464f..a82061a 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.12-develop1 +4.1.12-develop2 diff --git a/scripts/remove_cross-seed_tag.py b/scripts/remove_cross-seed_tag.py new file mode 100644 index 0000000..bd4daef --- /dev/null +++ b/scripts/remove_cross-seed_tag.py @@ -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)