mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-01 16:03:06 +01:00
43 lines
1.2 KiB
Python
Executable File
43 lines
1.2 KiB
Python
Executable File
#!/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")
|