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

Commit

Permalink
Added 1377x and RARBG support to searcher app
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbenb committed Mar 26, 2020
1 parent 7e20cb0 commit 7255053
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 44 deletions.
16 changes: 7 additions & 9 deletions rarbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
def rarbg():
def rarbg_callback():
rarbg_domain = rarbg_domain_entry.get()
if not rarbg_domain.endswith('/'):
rarbg_domain += '/'
rarbg_category = rarbg_category_entry.get()
rarbg_clipboard = rarbg_clipboard_combobox.get()
rarbg_link = rarbg_domain + 'rssdd.php?category=' + rarbg_category
try:
rarbg_request = requests.get(rarbg_link)
except:
messagebox.showinfo("RARBG Scraper @eliasbenb", "Something went wrong!")
messagebox.showinfo("RARBG Scraper @eliasbenb", "Something is wrong with the domain/category you inputed.\nMake sure that the domain ends with trailing '/'")

rarbg_source = rarbg_request.content
rarbg_soup = str(BeautifulSoup(rarbg_source, 'lxml'))
Expand All @@ -34,9 +32,9 @@ def rarbg_callback():

rarbg_timestr = time.strftime(" %Y%m%d%H%M%S")
rarbg_file_name = "RARBG Results " + rarbg_timestr + ".txt"
with open(rarbg_file_name,'w') as w1:
with open(rarbg_file_name,'w') as rarbg_w1:
for magnet in rarbg_magnets:
w1.write(magnet)
rarbg_w1.write(magnet)
messagebox.showinfo("RARBG Scraper @eliasbenb", "Magnet links successfully exported to local directory")

if rarbg_clipboard == "Yes":
Expand All @@ -48,8 +46,8 @@ def rarbg_callback():
def rarbg_load_config():
rarbg_domain_entry.delete(0,tkinter.END)
rarbg_category_entry.delete(0,tkinter.END)
with open(rarbg_path+"\\rarbg_config.env", "r") as r1:
rarbg_saved_config = [line.rstrip('\n') for line in r1]
with open(rarbg_path+"\\rarbg_config.env", "r") as rarbg_r1:
rarbg_saved_config = [line.rstrip('\n') for line in rarbg_r1]
rarbg_domain_entry.insert(0,rarbg_saved_config[0])
rarbg_category_entry.insert(0,rarbg_saved_config[1])
rarbg_clipboard_combobox.insert(0, rarbg_saved_config[2])
Expand All @@ -58,8 +56,8 @@ def rarbg_save_config():
rarbg_domain = rarbg_domain_entry.get()
rarbg_category = rarbg_category_entry.get()
rarbg_clipboard = rarbg_clipboard_combobox.get()
with open(rarbg_path+"\\rarbg_config.env", "w") as w2:
w2.write(rarbg_domain+'\n'+rarbg_category+'\n'+rarbg_clipboard)
with open(rarbg_path+"\\rarbg_config.env", "w") as rarbg_w2:
rarbg_w2.write(rarbg_domain+'\n'+rarbg_category+'\n'+rarbg_clipboard)

rarbg_app = Tk()

Expand Down
176 changes: 141 additions & 35 deletions search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,45 @@ def magnet_copy(event):
pyperclip.copy(magnet_choice)
messagebox.showinfo("Search Scraper @eliasbenb", "The selected magnet link was successfully copied to the clipboard")
search_query = search_query_entry.get()
if ('selected' in search_tpb_domain_checkbutton.state()) and ('selected' in search_kat_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
def search_kat():
search_kat_link = 'http://kat.rip/usearch/' + search_query
try:
search_kat_request = requests.get(search_kat_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something went wrong!")
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain/category you inputed.\nMake sure that the domain ends with trailing '/'")
search_kat_source = search_kat_request.text
search_kat_soup = BeautifulSoup(search_kat_source, 'lxml')
kat_search_titles_all = search_kat_soup.findAll('a', class_="cellMainLink")
for kat_title in kat_search_titles_all:
if kat_title not in search_magnet_combobox['values']:
search_magnet_combobox['values'] += (kat_title.text,)
search_kat_links = search_kat_soup.findAll('a', title="Torrent magnet link")
search_magnets=[]
for m in search_kat_links:
search_magnets.append(m['href'])

def search_rarbg():
search_rarbg_link = 'https://www.rarbgmirror.com/torrents.php?search=' + search_query
try:
search_rarbg_request = requests.get(search_rarbg_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain, please kindly inform me on my GitHub.")
search_rarbg_source = search_rarbg_request.text
search_rarbg_soup = BeautifulSoup(search_rarbg_source, 'lxml')
for page_link in search_rarbg_soup.findAll('a', attrs={'href': re.compile("^/torrent/")}):
rarbg_page_link = 'https://www.rarbgmirror.com/' + page_link.get('href')
try:
rarbg_page_request = requests.get(rarbg_page_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something went wrong!")

rarbg_page_source = rarbg_page_request.content
rarbg_page_soup = BeautifulSoup(rarbg_page_source, 'lxml')
link = rarbg_page_soup.find('a', attrs={'href': re.compile("^magnet")})
search_magnets.append(link.get('href'))
rarbg_title = rarbg_page_soup.find('h1')
search_magnet_combobox['values'] += (rarbg_title.text,)

def search_tpb():
search_tpb_link = 'https://tpb.party/search/' + search_query + '/1/99/0/'
try:
search_tpb_request = requests.get(search_tpb_link)
Expand All @@ -44,42 +65,119 @@ def magnet_copy(event):
search_tpb_links = search_tpb_soup.findAll('a', title="Download this torrent using magnet")
for m in search_tpb_links:
search_magnets.append(m['href'])
def search_x1377():
search_x1377_link = 'https://www.1377x.to/search/' + search_query + '/1/'
try:
search_x1377_request = requests.get(search_x1377_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain, please kindly inform me on my GitHub.")
search_1377x_source = search_x1377_request.text
search_1377x_soup = BeautifulSoup(search_1377x_source, 'lxml')
for page_link in search_1377x_soup.findAll('a', attrs={'href': re.compile("^/torrent/")}):
x1377_page_link = 'https://www.1377x.to/' + page_link.get('href')
try:
x1377_page_request = requests.get(x1377_page_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something went wrong!")

x1377_page_source = x1377_page_request.content
x1377_page_soup = BeautifulSoup(x1377_page_source, 'lxml')
link = x1377_page_soup.find('a', attrs={'href': re.compile("^magnet")})
search_magnets.append(link.get('href'))
x1377_title = x1377_page_soup.find('h1')
search_magnet_combobox['values'] += (x1377_title.text,)

if ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_rarbg()
search_tpb()
search_x1377()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_rarbg()
search_tpb()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_rarbg()
search_x1377()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_tpb()
search_x1377()

elif ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_rarbg()
search_tpb()
search_x1377()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_rarbg_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_rarbg()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_tpb()

elif ('selected' in search_kat_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_kat()
search_x1377()

elif ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_tpb_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_rarbg()
search_tpb()

elif ('selected' in search_rarbg_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_rarbg()
search_x1377()

elif ('selected' in search_tpb_domain_checkbutton.state()) and ('selected' in search_x1377_domain_checkbutton.state()):
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_tpb()
search_x1377()

elif 'selected' in search_kat_domain_checkbutton.state():
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_kat_link = 'http://kat.rip/usearch/' + search_query
try:
search_kat_request = requests.get(search_kat_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_kat_source = search_kat_request.text
search_kat_soup = BeautifulSoup(search_kat_source, 'lxml')
kat_search_titles_all = search_kat_soup.findAll('a', class_="cellMainLink")
for kat_title in kat_search_titles_all:
if kat_title not in search_magnet_combobox['values']:
search_magnet_combobox['values'] += (kat_title.text,)
search_kat_links = search_kat_soup.findAll('a', title="Torrent magnet link")
search_magnets=[]
for m in search_kat_links:
search_magnets.append(m['href'])
search_magnets = []
search_kat()

elif 'selected' in search_rarbg_domain_checkbutton.state():
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_rarbg()

elif 'selected' in search_tpb_domain_checkbutton.state():
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_tpb_link = 'https://tpb.party/search/' + search_query + '/1/99/0/'
try:
search_tpb_request = requests.get(search_tpb_link)
except:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain, please kindly inform me on my GitHub.")
search_tpb_source = search_tpb_request.text
search_tpb_soup = BeautifulSoup(search_tpb_source, 'lxml')
tpb_search_titles_all = search_tpb_soup.findAll('div', class_="detName")
for tpb_title in tpb_search_titles_all:
if tpb_title not in search_magnet_combobox['values']:
search_magnet_combobox['values'] += (tpb_title.text,)
search_tpb_links = search_tpb_soup.findAll('a', title="Download this torrent using magnet")
search_magnets=[]
for m in search_tpb_links:
search_magnets.append(m['href'])
search_magnets = []
search_tpb()

elif 'selected' in search_x1377_domain_checkbutton.state():
search_magnet_combobox['values'] = ['-- SELECT A MAGNET LINK TO COPY --']
search_magnets = []
search_x1377()

else:
messagebox.showinfo("Search Scraper @eliasbenb", "Something is wrong with the domain, please kindly inform me on my GitHub.")
Expand All @@ -90,12 +188,20 @@ def magnet_copy(event):

search_kat_domain_int = StringVar()
search_kat_domain_checkbutton = ttk.Checkbutton(search_app, text="KAT", variable=search_kat_domain_int)
search_kat_domain_checkbutton.place(relx=(2/5), rely=(1/20), anchor="center")
search_kat_domain_checkbutton.place(relx=(1/5), rely=(1/20), anchor="center")
search_kat_domain_checkbutton.state(['!disabled','selected'])
search_rarbg_domain_int = StringVar()
search_rarbg_domain_checkbutton = ttk.Checkbutton(search_app, text="RARBG", variable=search_rarbg_domain_int)
search_rarbg_domain_checkbutton.place(relx=(2/5), rely=(1/20), anchor="center")
search_rarbg_domain_checkbutton.state(['!disabled','selected'])
search_tpb_domain_int = StringVar()
search_tpb_domain_checkbutton = ttk.Checkbutton(search_app, text="TPB", variable=search_tpb_domain_int)
search_tpb_domain_checkbutton.place(relx=(3/5), rely=(1/20), anchor="center")
search_tpb_domain_checkbutton.state(['!disabled','selected'])
search_x1377_domain_int = StringVar()
search_x1377_domain_checkbutton = ttk.Checkbutton(search_app, text="1377x", variable=search_x1377_domain_int)
search_x1377_domain_checkbutton.place(relx=(4/5), rely=(1/20), anchor="center")
search_x1377_domain_checkbutton.state(['!disabled','selected'])

search_query_string = StringVar()
search_query_label = Label(search_app, text="Enter a Search Query:")
Expand Down

0 comments on commit 7255053

Please sign in to comment.