Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Commit

Permalink
Added a torrent searcher
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbenb committed Mar 21, 2020
1 parent 3544a38 commit da4e3b5
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from kat import kat
from rarbg import rarbg
from tpb import tpb
from searcher import searcher
from search import search
import os, webbrowser

path = '%s\\eliasbenb' % os.environ['APPDATA']
if not os.path.exists(path):
os.makedirs(path)
with open(path+'\\icon.ico','wb') as m1:
m1.write(icon_image_bytes)
with open(path+'\\website.png','wb') as m2:
m2.write(website_image_bytes)
with open(path+'\\github.png','wb') as m3:
m3.write(github_image_bytes)
with open(path+'\\eliasbenb.png','wb') as m4:
m4.write(eliasbenb_image_bytes)
with open(path+'\\icon.ico','wb') as w1:
w1.write(icon_image_bytes)
with open(path+'\\website.png','wb') as w2:
w2.write(website_image_bytes)
with open(path+'\\github.png','wb') as w3:
w3.write(github_image_bytes)
with open(path+'\\eliasbenb.png','wb') as w4:
w4.write(eliasbenb_image_bytes)

app = Tk()

Expand All @@ -29,8 +29,8 @@ def website_open():
def github_open():
webbrowser.open('https://github.com/eliasbenb/MagnetMagnet')

searcher_button = Button(app, text="Searcher", font=("Segoe UI", 15, "bold"), command=searcher)
searcher_button.place(relx=(0.5), rely=(75/275), anchor="s", height=75, width=450)
search_button = Button(app, text="Search", font=("Segoe UI", 15, "bold"), command=search)
search_button.place(relx=(0.5), rely=(75/275), anchor="s", height=75, width=450)

kat_button = Button(app, text="KAT", font=("Segoe UI", 15, "bold"), command=kat)
kat_button.place(relx=(1/6), rely=(225/275), anchor="s", height=150, width=150)
Expand Down
119 changes: 119 additions & 0 deletions search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from tkinter import Button, Entry, Label, messagebox, StringVar, Tk, ttk, Checkbutton, IntVar, BooleanVar
import os, pyperclip, requests, re, tkinter.ttk, time
from bs4 import BeautifulSoup

search_path = '%s\\eliasbenb' % os.environ['APPDATA']

def search():
def search_kat():
search_app.geometry('400x300')
search_kat_checkbutton.destroy()
search_tpb_checkbutton.destroy()
def search_search_callback():
def search_ok_callback_2():
search_choice = search_combobox.current()
magnet_choice = search_magnets[search_choice-1]
pyperclip.copy(magnet_choice)
messagebox.showinfo("Search Scraper @eliasbenb", "The selected magnet link was successfully copied to the clipboard")

search_search_button.destroy()
search_query = search_query_entry.get()
search_query = search_query.replace(' ', '%20')
search_link = 'http://kat.rip/usearch/' + search_query
try:
search_request = requests.get(search_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain/category you inputed.\nMake sure that the domain ends with trailing '/'")

search_source = search_request.text
search_soup = BeautifulSoup(search_source, 'lxml')

search_combobox = ttk.Combobox(search_app, values=['-- SELECT A MAGNET LINK TO COPY --'])
search_titles_all = search_soup.findAll('a', class_="cellMainLink")
for title in search_titles_all:
if title not in search_combobox['values']:
search_combobox['values'] += (title.text,)

search_links = search_soup.findAll('a', title="Torrent magnet link")
search_magnets=[]
for m in search_links:
search_magnets.append(m['href'])

search_combobox.place(relx=0.5, rely=0.3, anchor="center", width = 300)

search_ok_button_2 = Button(search_app, text = "OK", command = search_ok_callback_2)
search_ok_button_2.place(relx=0.5, rely=0.91, anchor="center")

search_query_text = StringVar()
search_query_label = Label(search_app, text="Enter Query:")
search_query_label.place(relx=0.5, rely=0.10, anchor="center")
search_query_entry = Entry(search_app, textvariable=search_query_text)
search_query_entry.place(relx=0.5, rely=0.20, anchor="center")

search_search_button = Button(search_app, text = "Search", command = search_search_callback)
search_search_button.place(relx=0.5, rely=0.91, anchor="center")

def search_tpb():
search_app.geometry('400x300')
search_kat_checkbutton.destroy()
search_tpb_checkbutton.destroy()
def search_search_callback():
def search_ok_callback_2():
search_choice = search_combobox.current()
magnet_choice = search_magnets[search_choice-1]
pyperclip.copy(magnet_choice)
messagebox.showinfo("Search Scraper @eliasbenb", "The selected magnet link was successfully copied to the clipboard")

search_search_button.destroy()
search_query = search_query_entry.get()
search_query = search_query.replace(' ', '%20')
search_link = 'https://tpb.party/search/' + search_query + '/1/99/0/'
try:
search_request = requests.get(search_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain/category you inputed.\nMake sure that the domain ends with trailing '/'")

search_source = search_request.text
search_soup = BeautifulSoup(search_source, 'lxml')

search_combobox = ttk.Combobox(search_app, values=['-- SELECT A MAGNET LINK TO COPY --'])
search_titles_all = search_soup.findAll('div', class_="detName")
for title in search_titles_all:
if title not in search_combobox['values']:
search_combobox['values'] += (title.text,)

search_links = search_soup.findAll('a', title="Download this torrent using magnet")
search_magnets=[]
for m in search_links:
search_magnets.append(m['href'])

search_combobox.place(relx=0.5, rely=0.3, anchor="center", width = 300)

search_ok_button_2 = Button(search_app, text = "OK", command = search_ok_callback_2)
search_ok_button_2.place(relx=0.5, rely=0.91, anchor="center")

search_query_text = StringVar()
search_query_label = Label(search_app, text="Enter Query:")
search_query_label.place(relx=0.5, rely=0.10, anchor="center")
search_query_entry = Entry(search_app, textvariable=search_query_text)
search_query_entry.place(relx=0.5, rely=0.20, anchor="center")

search_search_button = Button(search_app, text = "Search", command = search_search_callback)
search_search_button.place(relx=0.5, rely=0.91, anchor="center")

search_app = Tk()

search_kat_var = BooleanVar()
search_tpb_var = BooleanVar()

search_kat_checkbutton = Checkbutton(search_app, text="KAT", variable=search_kat_var, command=search_kat)
search_kat_checkbutton.place(relx=0.3, rely=0.5, anchor="center")
search_tpb_checkbutton = Checkbutton(search_app, text="TPB", variable=search_tpb_var, command=search_tpb)
search_tpb_checkbutton.place(relx=0.7, rely=0.5, anchor="center")


search_app.title('search @eliasbenb')
search_app.iconbitmap(search_path+'\\icon.ico')
search_app.geometry('250x100')

search_app.mainloop()

0 comments on commit da4e3b5

Please sign in to comment.