Initial commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
from os import system
|
||||
|
||||
#remove pre- and postfix from url, mainly for pinging
|
||||
def shortenUrl(host):
|
||||
host = host.replace("udp://", "")
|
||||
host = host.replace("tcp://", "")
|
||||
host = host.replace("http://", "")
|
||||
host = host.replace("https://", "")
|
||||
host = host.replace("/announce", "")
|
||||
newHost = ""
|
||||
for letter in host:
|
||||
if letter == ":":
|
||||
break
|
||||
else:
|
||||
newHost = newHost + letter
|
||||
return(newHost)
|
||||
|
||||
|
||||
def ping(host):
|
||||
if system(f"ping {host} -n 1") == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
f = open("input.txt", "r")
|
||||
trackers = f.read()
|
||||
f.close()
|
||||
|
||||
endList = []
|
||||
|
||||
for line in trackers.split():
|
||||
if line not in endList:
|
||||
url = shortenUrl(line)
|
||||
if ping(url) == True:
|
||||
endList.append(line)
|
||||
print(line + " " + "appended")
|
||||
else:
|
||||
print(line + " removed inactive tracker")
|
||||
else:
|
||||
print(line + " " + "removed duplicate")
|
||||
|
||||
|
||||
newList = open("output.txt", "w")
|
||||
for item in endList:
|
||||
newList.write(item + "\n")
|
||||
newList.close()
|
||||
|
||||
|
||||
|
||||
input("successfully wrote file")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user