mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2025-01-18 15:53:45 +01:00
Remove add_qbt_trackers.py; add resend_notify.py
This commit is contained in:
parent
516b4dacd3
commit
2ae4630a6b
@ -1,45 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
"""add_qbt_trackers.py
|
|
||||||
|
|
||||||
Description:
|
|
||||||
This script fetches torrent tracker URLs from plaintext lists hosted on the web
|
|
||||||
and adds them to each torrent in a qBittorrent instance.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
add_qbt_trackers.py (HOSTNAME) (USERNAME) (PASSWORD)
|
|
||||||
add_qbt_trackers.py -h
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
add_qbt_trackers.py "http://localhost:8080" "admin" "adminadmin"
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h, --help show this help message and exit
|
|
||||||
"""
|
|
||||||
|
|
||||||
import requests
|
|
||||||
from docopt import docopt
|
|
||||||
from qbittorrent import Client
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
args = docopt(__doc__) # type: ignore
|
|
||||||
|
|
||||||
# Initialize client and login
|
|
||||||
qb = Client(args["HOSTNAME"])
|
|
||||||
qb.login(username=args["USERNAME"], password=args["PASSWORD"])
|
|
||||||
|
|
||||||
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",
|
|
||||||
]
|
|
||||||
|
|
||||||
combined_trackers_urls = []
|
|
||||||
for url in live_trackers_list_urls:
|
|
||||||
response = requests.get(url, timeout=60)
|
|
||||||
tracker_urls = [x for x in response.text.splitlines() if x != ""]
|
|
||||||
combined_trackers_urls.extend(tracker_urls)
|
|
||||||
|
|
||||||
for torrent in qb.torrents():
|
|
||||||
qb.add_trackers(torrent.get("hash"), "\n".join(combined_trackers_urls)) # type: ignore
|
|
34
python/resend_notify.py
Executable file
34
python/resend_notify.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "resend",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import resend
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
resend.api_key = Path("/usr/local/etc/resend_api_key.txt").read_text().strip("\n")
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
exit("Usage: resend_notify.py SUBJECT MESSAGE")
|
||||||
|
subject = sys.argv[1]
|
||||||
|
message = sys.argv[2]
|
||||||
|
|
||||||
|
params: resend.Emails.SendParams = {
|
||||||
|
"from": "Admin <admin@hyperreal.coffee>",
|
||||||
|
"to": ["hyperreal@moonshadow.dev"],
|
||||||
|
"subject": subject,
|
||||||
|
"text": message,
|
||||||
|
}
|
||||||
|
|
||||||
|
email = resend.Emails.send(params)
|
||||||
|
print(email)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user