mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-11-10 00:10:46 +08:00
Adds new script to remove cross-seed tag
This commit is contained in:
parent
6af7ccac64
commit
f19a0c149c
2 changed files with 54 additions and 1 deletions
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
4.1.12-develop1
|
||||
4.1.12-develop2
|
||||
|
|
|
|||
53
scripts/remove_cross-seed_tag.py
Normal file
53
scripts/remove_cross-seed_tag.py
Normal 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)
|
||||
Loading…
Add table
Reference in a new issue