Skip to content

Commit

Permalink
add additional script to edit trackers
Browse files Browse the repository at this point in the history
  • Loading branch information
bobokun committed Oct 8, 2023
1 parent c1ec23a commit 9290d2c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.5-develop7
4.0.5-develop8
40 changes: 40 additions & 0 deletions scripts/edit_tracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/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
NEW_TRACKER = "https://blutopia.cc" # This is the tracker you want to replace it with
# --DEFINE VARIABLES--#
# --START SCRIPT--#

try:
from qbittorrentapi import Client, LoginFailed, APIConnectionError
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(hash=(torrent.hash), urls=(x.url))
torrent.add_trackers(hash=(torrent.hash), urls=(newurl))

0 comments on commit 9290d2c

Please sign in to comment.