Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start of python conversion for AddqBittorrentTrackers.sh #2

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
190 changes: 190 additions & 0 deletions AddqBittorrentTrackers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#!/usr/bin/env python3

########## CONFIGURATIONS ##########
# Host on which qBittorrent runs
qbt_host = "http://10.0.0.100"
# Port -> the same port that is inside qBittorrent option -> Web UI -> Web User Interface
qbt_port = "8081"
# Username to access to Web UI
qbt_username = "admin"
# Password to access to Web UI
qbt_password = "adminadmin"
# If true (lowercase) the script will inject trackers inside private torrent too (not a good idea)
ignore_private = False
# If true (lowercase) the script will remove all existing trackers before inject the new one, this functionality will works only for public trackers
clean_existing_trackers = False
# Configure here your trackers list
live_trackers_list_urls = [
"https://newtrackon.com/api/stable",
"https://trackerslist.com/best.txt",
"https://trackerslist.com/http.txt",
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt",
]
########## CONFIGURATIONS ##########

########## IMPORTS ##########
import qbittorrentapi # type: ignore
import requests # type: ignore
import argparse # type: ignore
########## IMPORTS ##########

########## VARIABLES ##########
auto_tor_grab=0
test_in_progress=0
applytheforce=0
all_torrent=0
emptycategory=0
########## VARIABLES ##########

########## FUNCTIONS ##########

def qbit_login(host, port, username, password):
# instantiate a Client using the appropriate WebUI configuration
conn_info = dict(
host=host,
port=port,
username=username,
password=password,
)
qbt_client = qbittorrentapi.Client(**conn_info)

# the Client will automatically acquire/maintain a logged-in state
# in line with any request. therefore, this is not strictly necessary;
# however, you may want to test the provided login credentials.
try:
qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)

return qbt_client

def generate_trackers_list():
live_trackers_list = []
for j in live_trackers_list_urls:
try:
response = requests.get(j)
live_trackers_list.extend(response.text.split())
except:
print(f"I can't parse the list from {j}")

if live_trackers_list == []:
live_trackers_list = [
"udp://tracker.coppersurfer.tk:6969/announce",
"http://tracker.internetwarriors.net:1337/announce",
"udp://tracker.internetwarriors.net:1337/announce",
"udp://tracker.opentrackr.org:1337/announce",
"udp://9.rarbg.to:2710/announce",
"udp://exodus.desync.com:6969/announce",
"udp://explodie.org:6969/announce",
"http://explodie.org:6969/announce",
"udp://public.popcorn-tracker.org:6969/announce",
"udp://tracker.vanitycore.co:6969/announce",
"http://tracker.vanitycore.co:6969/announce",
"udp://tracker1.itzmx.com:8080/announce",
"http://tracker1.itzmx.com:8080/announce",
"udp://ipv4.tracker.harry.lu:80/announce",
"udp://tracker.torrent.eu.org:451/announce",
"udp://tracker.tiny-vps.com:6969/announce",
"udp://tracker.port443.xyz:6969/announce",
"udp://open.stealth.si:80/announce",
"udp://open.demonii.si:1337/announce",
"udp://denis.stalker.upeer.me:6969/announce",
"udp://bt.xxx-tracker.com:2710/announce",
"http://tracker.port443.xyz:6969/announce",
"udp://tracker2.itzmx.com:6961/announce",
"udp://retracker.lanta-net.ru:2710/announce",
"http://tracker2.itzmx.com:6961/announce",
"http://tracker4.itzmx.com:2710/announce",
"http://tracker3.itzmx.com:6961/announce",
"http://tracker.city9x.com:2710/announce",
"http://torrent.nwps.ws:80/announce",
"http://retracker.telecom.by:80/announce",
"http://open.acgnxtracker.com:80/announce",
"wss://ltrackr.iamhansen.xyz:443/announce",
"udp://zephir.monocul.us:6969/announce",
"udp://tracker.toss.li:6969/announce",
"http://opentracker.xyz:80/announce",
"http://open.trackerlist.xyz:80/announce",
"udp://tracker.swateam.org.uk:2710/announce",
"udp://tracker.kamigami.org:2710/announce",
"udp://tracker.iamhansen.xyz:2000/announce",
"udp://tracker.ds.is:6969/announce",
"udp://pubt.in:2710/announce",
"https://tracker.fastdownload.xyz:443/announce",
"https://opentracker.xyz:443/announce",
"http://tracker.torrentyorg.pl:80/announce",
"http://t.nyaatracker.com:80/announce",
"http://open.acgtracker.com:1096/announce",
"wss://tracker.openwebtorrent.com:443/announce",
"wss://tracker.fastcast.nz:443/announce",
"wss://tracker.btorrent.xyz:443/announce",
"udp://tracker.justseed.it:1337/announce",
"udp://thetracker.org:80/announce",
"udp://packages.crunchbangplusplus.org:6969/announce",
"https://1337.abcvg.info:443/announce",
"http://tracker.tfile.me:80/announce.php",
"http://tracker.tfile.me:80/announce",
"http://tracker.tfile.co:80/announce",
"http://retracker.mgts.by:80/announce",
"http://peersteers.org:80/announce",
"http://fxtt.ru:80/announce",
]

return live_trackers_list

def inject_trackers(client, hash):
print("\e[0;36;1mInjecting... \e[0;36m")

torrent_trackers = []
for tracker in client.torrents_trackers(torrent_hash=hash):
if tracker.url.startswith("** ["):
continue
torrent_trackers.append(tracker.url)

return torrent_trackers

# main function
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog='AddqBittorrentTrackers',
description='Add trackers to torrents in qBittorrent',
)
parser.add_argument(
'-H',
'--host',
default=qbt_host,
help="Host on which qBittorrent runs",
)
parser.add_argument(
'-p',
'--port',
default=qbt_port,
help="Port used to access the Web UI",
)
parser.add_argument(
'-U',
'--username',
default=qbt_username,
help="Username to access to Web UI",
)
parser.add_argument(
'-P',
'--password',
default=qbt_password,
help="Password to access to Web UI",
)
parser.add_argument(
'--debug',
action="store_true",
default=False,
help="Print debug statements instead of taking action",
)
args = parser.parse_args()

# Login
client = qbit_login(args.host, args.port, args.username, args.password)

# WIP
hash = ""
torrent_trackers = inject_trackers(client, hash)
print(torrent_trackers)