mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Add fetch_combined_trackers_list.py
This commit is contained in:
parent
b01b077730
commit
63df2f94d4
12
README.org
12
README.org
@ -3,11 +3,13 @@
|
|||||||
These are scripts I use to automate various tasks in my homelab.
|
These are scripts I use to automate various tasks in my homelab.
|
||||||
|
|
||||||
** bin
|
** bin
|
||||||
- ~add_scihub_torrents~ : This script uses [[https://github.com/charmbracelet/gum][gum]] to select paginated text files that contain URLs of Sci Hub torrent files. For each selected file, the URLs are read and added to a qBittorrent instance.
|
- ~add_qbt_trackers.py~ : This script fetches torrent tracker URLs from plaintext files hosted on the web and adds them to each torrent in a qBittorrent instance.
|
||||||
- ~qbth~ : This is a helper program for adding Linux and BSD distros to a qBittorrent instance. It's a bit crude, and the Python linter yells at me for it, but it gets the job done, and that's all I need it to do. Thank you.
|
- ~add_scihub_torrents.py~ : This script uses [[https://github.com/charmbracelet/gum][gum]] to select paginated text files that contain URLs of Sci Hub torrent files. For each selected file, the URLs are read and added to a qBittorrent instance.
|
||||||
- ~qbt_sum_size~ : This script prints the total size of completed torrents and the total size of all torrents added to a qBittorrent instance. The former is a subset of the latter.
|
- ~fetch_combined_trackers_list.py~ : This script fetches a combined list of tracker URLs from plaintext files hosted on the web and writes them to a file in the current working directory.
|
||||||
- ~seed_armbian_torrents~ : This script downloads an archive from Armbian, extracts the torrent files within to a temporary directory, and adds each file to a qBittorrent instance. It first removes older Armbian torrents from the qBittorrent instance.
|
- ~qbth.py~ : This is a helper program for adding Linux and BSD distros to a qBittorrent instance. It's a bit crude, and the Python linter yells at me for it, but it gets the job done, and that's all I need it to do. Thank you.
|
||||||
- ~seed_scihub_torrents~ : This script finds which torrents have less than or equal to N seeders, where N is an integer argument supplied by the user. It then adds these torrents to a qBittorrent instance.
|
- ~qbt_sum_size.py~ : This script prints the total size of completed torrents and the total size of all torrents added to a qBittorrent instance. The former is a subset of the latter.
|
||||||
|
- ~seed_armbian_torrents.py~ : This script downloads an archive from Armbian, extracts the torrent files within to a temporary directory, and adds each file to a qBittorrent instance. It first removes older Armbian torrents from the qBittorrent instance.
|
||||||
|
- ~seed_scihub_max_seeders.py~ : This script finds which torrents have less than or equal to N seeders, where N is an integer argument supplied by the user. It then adds these torrents to a qBittorrent instance.
|
||||||
- ~server0_backup~ : This script dumps my Mastodon instance's PostgreSQL database, then uses rclone to sync ~/etc~, ~/var/log~, and ~/home/jas~ to an S3-compatible object storage bucket (MinIO). It also copies the dumped Mastodon database and ~.env.production~ to the object storage bucket.
|
- ~server0_backup~ : This script dumps my Mastodon instance's PostgreSQL database, then uses rclone to sync ~/etc~, ~/var/log~, and ~/home/jas~ to an S3-compatible object storage bucket (MinIO). It also copies the dumped Mastodon database and ~.env.production~ to the object storage bucket.
|
||||||
|
|
||||||
** systemd
|
** systemd
|
||||||
|
@ -22,7 +22,7 @@ from docopt import docopt
|
|||||||
from qbittorrent import Client
|
from qbittorrent import Client
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = docopt(__doc__)
|
args = docopt(__doc__) # type: ignore
|
||||||
|
|
||||||
# Initialize client and login
|
# Initialize client and login
|
||||||
qb = Client(args["HOSTNAME"])
|
qb = Client(args["HOSTNAME"])
|
||||||
@ -43,5 +43,5 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for torrent in qb.torrents():
|
for torrent in qb.torrents():
|
||||||
for tracker in combined_trackers_urls:
|
for tracker in combined_trackers_urls:
|
||||||
qb.add_trackers(torrent.get("hash"), f"{tracker}\n") # type: ignore
|
qb.add_trackers(torrent.get("hash"), f"{tracker}\n") # type: ignore
|
||||||
print(f"Added {tracker} to {torrent.get("name")}") # type: ignore
|
print(f"Added {tracker} to {torrent.get('name')}") # type: ignore
|
||||||
|
42
bin/fetch_combined_trackers_list.py
Executable file
42
bin/fetch_combined_trackers_list.py
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""fetch_combined_trackers_list.py
|
||||||
|
|
||||||
|
Description:
|
||||||
|
This script fetches a combined list of tracker URLs from plaintext lists hosted
|
||||||
|
on the web and writes them to a file in the current working directory.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
fetch_combined_trackers_list.py
|
||||||
|
fetch_combined_trackers_list.py -h
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from docopt import docopt
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = docopt(__doc__) # type: ignore
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
current_working_directory = Path.cwd()
|
||||||
|
tracker_urls_filename = Path.cwd().joinpath("tracker_urls.txt")
|
||||||
|
with open(tracker_urls_filename, "w") as tf:
|
||||||
|
for url in combined_trackers_urls:
|
||||||
|
tf.write(f"{url}\n")
|
Loading…
Reference in New Issue
Block a user