Created
September 5, 2021 11:10
-
-
Save DoctorD90/7b1cce0f7b97254f724e9c7e3f7faaec to your computer and use it in GitHub Desktop.
Generate a clean formatted trackers list for torrents softwares
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate a clean formatted trackers list for torrents softwares | |
# The newtrackon.com free service is used as main resource | |
INPUT_FILE="torlist_input.txt" | |
OUTPUT_FILE="torlist_output.txt" | |
# Create input file | |
if [ ! -e "$INPUT_FILE" ]; then | |
touch "$INPUT_FILE" | |
fi | |
# Download the LIVE list by newtrackon.com | |
curl https://newtrackon.com/api/live >> "$INPUT_FILE" | |
# Merge the previous checked with the new one | |
if [ -e "$OUTPUT_FILE" ]; then | |
cat "$OUTPUT_FILE" >> "$INPUT_FILE" | |
fi | |
# Clean up input_file from duplicates | |
torinput="$(cat "$INPUT_FILE" | grep . | sort -u)" | |
echo "$torinput" > "$INPUT_FILE" | |
# Remove protocols and duplicates | |
tortemp="$(cat "$INPUT_FILE" | sed 's,https://,,g' | sed 's,http://,,g' | sed 's,udp://,,g' | sort -u)" | |
# Remove IPS without rDNS | |
torips="$(echo "$tortemp" | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sort -u)" | |
for ip in $torips; do | |
echo "Checking IP $ip" | |
out="$(host "$ip")" | |
if echo "$out" | grep -q "not found"; then | |
echo "$ip - rDNS not found" | |
tortemp="$(echo "$tortemp" | sed '/'"$ip"'/d')" | |
else | |
echo "$ip - rDNS found" | |
fi | |
done | |
# Add multiple protocols for each tracker | |
tortrackers="$(echo "$tortemp" | cut -d "/" -f1 | cut -d ":" -f1 | sort -u)" | |
rm -rf "$OUTPUT_FILE" | |
for tracker in $tortrackers; do | |
trackers="$(echo "$tortemp" | grep "$tracker")" | |
for track in $trackers; do | |
echo -e "https://$track\nhttp://$track\nudp://$track\n" >> "$OUTPUT_FILE" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment