admin-scripts/fetch_combined_trackers_list.py

48 lines
1.3 KiB
Python
Raw Normal View History

2024-11-09 00:18:47 +01:00
# /// script
# dependencies = [
# "requests",
# "docopt",
# ]
# ///
2024-07-31 02:44:14 +02:00
"""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__":
2024-11-09 00:18:47 +01:00
args = docopt(__doc__) # type: ignore
2024-07-31 02:44:14 +02:00
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")