There is an option in qBittorrent to automatically add trackers to new downloads (Options -> BitTorrent).
I was wondering whether it's possible to use the following API to have the option to automatically use all stable and/or working trackers with new downloads.
https://newtrackon.com/api
Would be nice to have so you don't have to update them yourself to get rid of all the dead trackers....
Automatically add trackers through API
Re: Automatically add trackers through API
Oh we (like pretty much everyone in the community/online) use: https://github.com/ngosang/trackerslist
You could write a small script, to replace the relevant file in the settings of qBittorrent, to use a fresh fetch from ngosang's list.
Like... it depends on your platform where the .ini file is, but it's qBittorrent.ini in %APPDATA%\qBittorrent on Windows.
And the line is: Session\AdditionalTrackers=
So basically, in Python for example:
(
this is for Windows, uh, do whatever you want with it.
- you have to enable the options for this to work, because it does not look/care if its enabled or not
- you have to add a single tracker, or multiple trackers before you run this because it looks for the AdditionalTrackers line in config file
- it does not do any kind of backup of your backup, so I recommend backing up your config files before running it
)
You could write a small script, to replace the relevant file in the settings of qBittorrent, to use a fresh fetch from ngosang's list.
Like... it depends on your platform where the .ini file is, but it's qBittorrent.ini in %APPDATA%\qBittorrent on Windows.
And the line is: Session\AdditionalTrackers=
So basically, in Python for example:
(
this is for Windows, uh, do whatever you want with it.
- you have to enable the options for this to work, because it does not look/care if its enabled or not
- you have to add a single tracker, or multiple trackers before you run this because it looks for the AdditionalTrackers line in config file
- it does not do any kind of backup of your backup, so I recommend backing up your config files before running it
)
Code: Select all
import os # to get AppData
from urllib.request import urlopen # to download new tracker list
CONFIG_PATH = os.getenv('APPDATA') + "\\qBittorrent\\qBittorrent.ini"
def get_fresh_trackers():
url = 'https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt'
output = urlopen(url).read()
return output.decode('utf-8')
def process_config_tracker_list(tracker_list: str):
returned_string = ""
tracker_list_split = tracker_list.split('\n')
for e in tracker_list_split:
e: str
if e: # string not empty
returned_string += e
returned_string += "\\n\\n"
return "Session\\AdditionalTrackers=" + returned_string
if __name__ == '__main__':
tracker_list = process_config_tracker_list(get_fresh_trackers())
final_lines = []
# read the current config file
with open(CONFIG_PATH) as qbit_config_file:
config_lines = qbit_config_file.readlines()
# replace the line with the new trackers
for config_line in config_lines:
if config_line.startswith("Session\\AdditionalTrackers"):
config_line = tracker_list + os.linesep
final_lines.append(config_line)
# write out ready config file
with open(CONFIG_PATH, "w") as qbit_config_file:
qbit_config_file.writelines(final_lines)