mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-09 13:29:15 +08:00
* 4.2.1-develop1 * Adds #747 * Fixes #764 * Replaced pre-commit hooks flake8, black, pyupgrade, etc. with ruff for linting and formatting. * Bump ruff from 0.9.10 to 0.10.0 (#767) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.10 to 0.10.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.10...0.10.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * 4.2.1 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# This standalone script is used to edit tracker urls from one tracker to another.
|
|
# Needs to have qbittorrent-api installed
|
|
# pip3 install qbittorrent-api
|
|
import sys
|
|
|
|
# --DEFINE VARIABLES--#
|
|
qbt_host = "qbittorrent:8080"
|
|
qbt_user = None
|
|
qbt_pass = None
|
|
OLD_TRACKER = "https://blutopia.xyz" # This is the tracker you want to replace
|
|
# This is the tracker you want to replace it with
|
|
NEW_TRACKER = "https://blutopia.cc"
|
|
# --DEFINE VARIABLES--#
|
|
# --START SCRIPT--#
|
|
|
|
try:
|
|
from qbittorrentapi import APIConnectionError
|
|
from qbittorrentapi import Client
|
|
from qbittorrentapi import LoginFailed
|
|
except ModuleNotFoundError:
|
|
print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
client = Client(host=qbt_host, username=qbt_user, password=qbt_pass)
|
|
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.")
|
|
torrent_list = client.torrents.info(sort="added_on", reverse=True)
|
|
|
|
for torrent in torrent_list:
|
|
for x in torrent.trackers:
|
|
if OLD_TRACKER in x.url:
|
|
newurl = x.url.replace(OLD_TRACKER, NEW_TRACKER)
|
|
print(f"torrent name: {torrent.name}, original url: {x.url}, modified url: {newurl}\n")
|
|
torrent.remove_trackers(urls=x.url)
|
|
torrent.add_trackers(urls=newurl)
|