-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add additional script to edit trackers
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.0.5-develop7 | ||
4.0.5-develop8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |