Skip to content

Instantly share code, notes, and snippets.

@krishnachaitanya7
Last active August 30, 2015 16:54
Show Gist options
  • Save krishnachaitanya7/e3481113272e1410bff4 to your computer and use it in GitHub Desktop.
Save krishnachaitanya7/e3481113272e1410bff4 to your computer and use it in GitHub Desktop.
Many of them copy tracker URL's from internet to paste them for torrent downloading to get started, but adding them is a bit boring work. finding which tracker URL is already present. Let computer do that. Read the instructions to use in this Gist
'''
make a python file and name it whatever you want. make a text file named trackers.txt and paste all the list of exhaustive trackers in that text file. now copy the tracker url's you have obtained from the torrent file to the clipboard and run this python script. now paste the exhaustive list into your torrent downloading software along with updated url's you have obtained from the torrent file. Any new url's will be automatically updated in tracker.txt file. this script uses boyer moore horspool string searching algorithm
If it helped you i would love to hear from you. i would also be grateful if you post it in any of your groups and somebody uses it. mail me or message me: chaitanyaradon89@gmail.com, kcradon11@facebook.com
'''
import pyperclip
def BoyerMooreHorspool(pattern, text):
m = len(pattern)
n = len(text)
if m > n: return -1
skip = []
for k in range(256): skip.append(m)
for k in range(m - 1): skip[ord(pattern[k])] = m - k - 1
skip = tuple(skip)
k = m - 1
while k < n:
j = m - 1; i = k
while j >= 0 and text[i] == pattern[j]:
j -= 1; i -= 1
if j == -1: return i + 1
k += skip[ord(text[k])]
return -1
if __name__ == '__main__':
with open ("trackers.txt", "r") as myfile:
data=myfile.read()
tracker_clipboard = pyperclip.paste()
content = tracker_clipboard.split()
for pattern in content:
s = BoyerMooreHorspool(pattern, data)
if s == -1:
with open("trackers.txt", "a") as text_file:
text_file.write(pattern)
text_file.write("\n")
with open("trackers.txt", "r") as final_file:
final_data = final_file.read()
pyperclip.copy(final_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment