Last active
November 17, 2015 04:00
-
-
Save anonymous/495cb3660fdaa0145943 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import requests | |
from bs4 import BeautifulSoup | |
import os | |
import re | |
from Tkinter import * | |
try: | |
input = raw_input | |
except NameError: | |
pass | |
def clearhistory(): | |
file_ = open('history.txt', 'w') | |
file_.close() | |
def addhistory(): | |
global read | |
global j | |
bong1 = j1[va.get()] | |
bong2 = j[va.get()] | |
file_ = open('history.txt', 'a') | |
file_.write(str(bong1[9:]).replace("/", "")+ "|||") | |
file_.write("{}|||".format(bong2)) | |
file_.close() | |
def history(): | |
global j10 | |
global history1 | |
history1 = Toplevel() | |
history1.geometry("450x475+200+80") | |
file_ = open('history.txt', 'r') | |
john = file_.read() | |
x9 = john.split("|||") | |
x1 = filter(None, x9) | |
file_.close() | |
jen1 = x1[::-1] | |
counting = 0 | |
j10 = jen1[0::2] | |
if len(jen1) > 34: | |
global jen2 | |
jen2 = jen1[:34:] | |
jen3 = jen2[::-1] | |
jen4 = jen2[1::2] | |
file_ = open('history.txt', 'w') | |
for x in jen3: | |
file_.write(str(x) + "|||") | |
for x in jen4: | |
R4 = Radiobutton(history1, text = "{}".format(x), value = counting, variable = ga).pack() | |
counting += 1 | |
file_.close() | |
else: | |
for h in jen1[1::2]: | |
R4 = Radiobutton(history1, text = "{}".format(h), value = counting, variable = ga).pack() | |
counting += 1 | |
butframe = Frame(history1) | |
mbutton2 = Button(butframe, text = "Chromecast", command = historycast) | |
mbutton2.pack(side=LEFT, pady=10) | |
mbutton1 = Button(butframe, text = "VLC", command = historyplayer) | |
mbutton1.pack(side=LEFT, padx=10) | |
mbutton4 = Button(butframe, text = "MPC", command = historympc) | |
mbutton4.pack(side=LEFT) | |
mbutton10 = Button(butframe, text = "Clear History", command = clearhistory) | |
mbutton10.pack(side=LEFT, padx =10) | |
butframe.pack(side=BOTTOM) | |
def reddit(): | |
Toplevel.destroy(weld) | |
os.system('start /max www.reddit.com/r/Peerflixr') | |
def subtitleget(event = None): | |
Toplevel.destroy(subsearch6) | |
subtitlesearch = subsearch1.get() | |
check4 = subtitlesearch.replace(" ", "-") | |
query2 = "http://subsmax.com/subtitles-movie/{}/ni".format(check4) | |
r = requests.get(query2) | |
soup = BeautifulSoup(r.content, "html.parser") | |
t = [] | |
for link in soup.find_all('a'): | |
text = link.get('href') | |
t.append(text) | |
os.system('start /max {}'.format(t[4])) | |
def subsearch(): | |
global subsearch6 | |
global subsearch1 | |
subsearch6 = Toplevel() | |
subsearch6.geometry('260x120+350+100') | |
mlabel = Label(subsearch6, text = 'Enter Full Movie Title and Subtitle Language').pack() | |
mlabel = Label(subsearch6, text = 'Ex. "Mad Max Fury Road Spanish"').pack() | |
mlabel = Label(subsearch6, text = 'For shows - include episode in "s01e01" format').pack() | |
mentry = Entry(subsearch6, textvariable = subsearch1, width=25).pack() | |
mbutton = Button(subsearch6, text = 'Download', command = subtitleget).pack(pady=5) | |
subsearch6.bind('<Return>', subtitleget) | |
def website(): | |
num = va.get() | |
os.system('start /max {}'.format(final[num])) | |
def historycast(): | |
global w | |
global subs | |
w = Toplevel() | |
w.geometry('200x153+350+100') | |
mlabel = Label(w, text = 'Chromecast Name (optional)').pack() | |
mentry = Entry(w, textvariable = joe).pack() | |
mlabel = Label(w, text = 'Chromecast IP (optional)').pack() | |
mentry = Entry(w, textvariable = joey).pack() | |
mlabel = Label(w, text = 'Link or path to Subtitles (optional)').pack() | |
mentry = Entry(w, textvariable = subs).pack() | |
mbutton = Button(w, text = 'Cast', command = cast1).pack(pady=3) | |
w.bind('<Return>', historycast1) | |
def historycast1(event = None): | |
global w | |
Toplevel.destroy(history1) | |
addhistory() | |
Toplevel.destroy(w) | |
subtitles = subs.get() | |
joe1 = joe.get() | |
joey1 = joey.get() | |
link1 = ga.get() | |
link = 'magnet'+j10[int(link1)] | |
if joey1 == "" and joe1 == "" and subtitles == "": | |
os.system('castnow "{}"'.format(link)) | |
elif joey1 == "" and subtitles == "": | |
os.system('castnow "{}" --device {}'.format(link, joe1)) | |
elif joe1 == "" and subtitles == "": | |
os.system('castnow "{}" --address {}'.format(link, joey1)) | |
elif joe1 == "" and joey1 == "": | |
os.system('castnow "{}" --subtitles {}'.format(link, subtitles)) | |
elif subtitles == "": | |
os.system('castnow "{}" --address {} --device {}'.format(link, joey1, joe1)) | |
elif joey1 == "": | |
os.system('castnow "{}" --device {} subtitles {}'.format(link, joe1, subtitles)) | |
elif joe1 == "": | |
os.system('castnow "{}" --address {} --subtitles {}'.format(link, joey1, subtitles)) | |
else: | |
os.system('castnow "{}" --device {} --address {} --subtitles {}'.format(link, joe1, joey1, subtitles)) | |
def cast(): | |
global w | |
global subs | |
w = Toplevel() | |
w.geometry('200x153+350+100') | |
mlabel = Label(w, text = 'Chromecast Name (optional)').pack() | |
mentry = Entry(w, textvariable = joe).pack() | |
mlabel = Label(w, text = 'Chromecast IP (optional)').pack() | |
mentry = Entry(w, textvariable = joey).pack() | |
mlabel = Label(w, text = 'Link or path to Subtitles (optional)').pack() | |
mentry = Entry(w, textvariable = subs).pack() | |
mbutton = Button(w, text = 'Cast', command = cast1).pack(pady=3) | |
w.bind('<Return>', cast1) | |
def cast1(event = None): | |
global w | |
addhistory() | |
Toplevel.destroy(w) | |
subtitles = subs.get() | |
joe1 = joe.get() | |
joey1 = joey.get() | |
link1 = va.get() | |
link = 'magnet'+j[int(link1)] | |
if joey1 == "" and joe1 == "" and subtitles == "": | |
os.system('castnow "{}"'.format(link)) | |
elif joey1 == "" and subtitles == "": | |
os.system('castnow "{}" --device {}'.format(link, joe1)) | |
elif joe1 == "" and subtitles == "": | |
os.system('castnow "{}" --address {}'.format(link, joey1)) | |
elif joe1 == "" and joey1 == "": | |
os.system('castnow "{}" --subtitles {}'.format(link, subtitles)) | |
elif subtitles == "": | |
os.system('castnow "{}" --address {} --device {}'.format(link, joey1, joe1)) | |
elif joey1 == "": | |
os.system('castnow "{}" --device {} subtitles {}'.format(link, joe1, subtitles)) | |
elif joe1 == "": | |
os.system('castnow "{}" --address {} --subtitles {}'.format(link, joey1, subtitles)) | |
else: | |
os.system('castnow "{}" --device {} --address {} --subtitles {}'.format(link, joe1, joey1, subtitles)) | |
def magcast(): | |
Toplevel.withdraw(maggy) | |
global w | |
w = Toplevel() | |
w.geometry('200x153+350+100') | |
mlabel = Label(w, text = 'Chromecast Name (optional)').pack() | |
mentry = Entry(w, textvariable = joe4).pack() | |
mlabel = Label(w, text = 'Chromecast IP (optional)').pack() | |
mentry = Entry(w, textvariable = joey4).pack() | |
mlabel = Label(w, text = 'Link or path to Subtitles (optional)').pack() | |
mentry = Entry(w, textvariable = subs1).pack() | |
mbutton = Button(w, text = 'Cast', command = magcast1).pack(pady=3) | |
w.bind('<Return>', magcast1) | |
def magcast1(event = None): | |
global w | |
Toplevel.destroy(w) | |
joe5 = joe4.get() | |
joey5 = joey4.get() | |
link = maglink.get() | |
subtitles1 = subs1.get() | |
Toplevel.destroy(maggy) | |
if joey5 == "" and joe5 == "" and subtitles1 == "": | |
os.system('castnow "{}"'.format(link)) | |
elif joey5 == "" and subtitles1 == "": | |
os.system('castnow "{}" --device {}'.format(link, joe5)) | |
elif joe5 == "" and subtitles1 == "": | |
os.system('castnow "{}" --address {}'.format(link, joey5)) | |
elif joe5 == "" and joey5 == "": | |
os.system('castnow "{}" --subtitles {}'.format(link, subtitles1)) | |
elif subtitles1 == "": | |
os.system('castnow "{}" --address {} --device {}'.format(link, joey5, joe5)) | |
elif joey5 == "": | |
os.system('castnow "{}" --device {} subtitles {}'.format(link, joe5, subtitles1)) | |
elif joe5 == "": | |
os.system('castnow "{}" --address {} --subtitles {}'.format(link, joey5, subtitles1)) | |
else: | |
os.system('castnow "{}" --device {} --address {} --subtitles {}'.format(link, joe5, joey5, subtitles1)) | |
def magplayer(): | |
linker = maglink.get() | |
Toplevel.destroy(maggy) | |
os.system('peerflix "{}" --vlc -d'.format(linker)) | |
def magmpc(): | |
link1=maglink.get() | |
Toplevel.destroy(maggy) | |
os.system('peerflix "{}" --mpchc -d'.format(link1)) | |
def historympc(): | |
Toplevel.destroy(history1) | |
link1 = ga.get() | |
link = 'magnet'+j10[int(link1)] | |
os.system('peerflix "{}" --mpchc -d'.format(link)) | |
def mpc(): | |
addhistory() | |
link1 = va.get() | |
link = 'magnet'+j[int(link1)] | |
os.system('peerflix "{}" --mpchc -d'.format(link)) | |
def historyplayer(): | |
Toplevel.destroy(history1) | |
link1 = ga.get() | |
link = 'magnet'+j10[int(link1)] | |
os.system('peerflix "{}" --vlc -d'.format(link)) | |
def player(): | |
addhistory() | |
link1 = va.get() | |
link = 'magnet'+j[int(link1)] | |
os.system('peerflix "{}" --vlc -d'.format(link)) | |
def johnson(): | |
global weld | |
weld = Toplevel() | |
weld.geometry('250x75+350+100') | |
mlabel = Label(weld, text = "For more information or to donate visit:").pack() | |
mlabel = Label(weld, text = "www.reddit.com/r/Peerflixr").pack() | |
mbutton = Button(weld, text = "Visit Site", command = reddit).pack() | |
def helping(): | |
helly = Toplevel() | |
helly.geometry('400x90+350+120') | |
mlabel = Label(helly, text = "For Movies - Include release year for better results").pack() | |
mlabel = Label(helly, text = "For TV Shows - Include episode in 'S01E01' format").pack() | |
mlabel = Label(helly, text = "Subtitle files must be in .vtt or .srt format").pack() | |
mlabel = Label(helly, text = "To easily copy a file path - Shift-Right click a file and select 'copy as path'").pack() | |
def magnet(): | |
global maglink | |
global maggy | |
maggy = Toplevel() | |
maggy.geometry('200x75+350+100') | |
mlabel = Label(maggy, text = "Enter magnet link here (Ctrl-v)").pack() | |
mentry = Entry(maggy, textvariable = maglink).pack() | |
butframe1 = Frame(maggy) | |
mbutton = Button(butframe1, text = "VLC", command = magplayer).pack(side=LEFT, pady=3) | |
mbutton = Button(butframe1, text = "Chromecast", command = magcast).pack(side=LEFT, padx=3) | |
mbutton = Button(butframe1, text = "MPC", command = magmpc).pack(side=LEFT) | |
butframe1.pack(side=BOTTOM) | |
gui = Tk() | |
subsearch1 = StringVar() | |
subs1 = StringVar() | |
check1 = StringVar() | |
subs = StringVar() | |
ga = IntVar() | |
va = IntVar() | |
joe4 = StringVar() | |
joey4 = StringVar() | |
maglink = StringVar() | |
joe = StringVar() | |
joey = StringVar() | |
ment = StringVar() | |
count = 0 | |
gui.geometry('500x505+300+25') | |
gui.title ('Peerflixr V1.4') | |
menubar = Menu(gui) | |
menubar.add_cascade(label = "Magnet", command=magnet) | |
menubar.add_cascade(label = "Subtitles", command=subsearch) | |
menubar.add_cascade(label = "History", command=history) | |
menubar.add_cascade(label = "Help", command=helping) | |
menubar.add_cascade(label = "Info", command=johnson) | |
gui.config(menu=menubar) | |
# Printing out torrent titles | |
def list1(event = None): | |
global count | |
global mlabel1 | |
global mbutton1 | |
global mbutton2 | |
global mbutton3 | |
global mbutton4 | |
global butframe | |
if count > 0: | |
for x in y: | |
x.pack_forget() | |
x.destroy() | |
for x in m: | |
x.pack_forget() | |
x.destroy() | |
mbutton4.pack_forget() | |
butframe.pack_forget() | |
mlabel1.pack_forget() | |
mbutton1.pack_forget() | |
mbutton2.pack_forget() | |
mbutton3.pack_forget() | |
count = count+1 | |
# Creating link | |
check = check1.get() | |
query = "http://thepiratebay.gd/search/{}/0/99/200".format(check) | |
r = requests.get(query) | |
soup = BeautifulSoup(r.content, "html.parser") | |
# Torrent website | |
global final | |
w = [] | |
for x in soup.find_all('a'): | |
w.append(x) | |
penis = [] | |
for x in w[19::]: | |
john = str(x).split("torrent")[1:2] | |
penis.append(john) | |
hope = filter(None, penis) | |
tess = [] | |
johnjohn = hope[0::2] | |
for x in johnjohn: | |
tess.append(str(x).rsplit('"', 3)[0]) | |
final = [] | |
for x in tess: | |
jj = "http://thepiratebay.gd/torrent{}".format(str(x)[2:]) | |
final.append(jj) | |
# Finding seeds and leachers | |
q = [] | |
seeders = [] | |
leachers = [] | |
for x in soup.find_all('td'): | |
q.append(x) | |
seeds = q[2:32:4] | |
for x in seeds: | |
seeders.append(str(x)[18:23]) | |
leacher = q[3:32:4] | |
for x in leacher: | |
leachers.append(str(x)[18:22]) | |
# Finding file sizes | |
sizelist = [] | |
size = q[1:32:4] | |
for x in size: | |
size1 = (str(x).split("Size")[1:2]) | |
finalsize = (str(size1)[2:7]) | |
sizelist.append(finalsize) | |
# title and magnet link lists | |
global j | |
global read | |
j = [] | |
read = [] | |
# filtering out un-needed data and creating lists | |
for link in soup.find_all('a'): | |
text = link.get('href') | |
title = text.split("torrent")[1:2] | |
for h in title: | |
if h != " ": | |
read.append(h) | |
magnet = text.split("magnet")[1:2] | |
for x in magnet: | |
if x != " ": | |
j.append(x) | |
# Grabbing list items containing torrent titles | |
global j1 | |
global o | |
global y | |
global m | |
m = [] | |
y = [] | |
o = 0 | |
j1 = read[0:16:2] | |
mlabel1 = Label(gui, text = "***Make a Selection***") | |
mlabel1.pack() | |
for t in j1: | |
R1 = Radiobutton(gui, text = "{}".format(t[9:]).replace("/", " "), value = o, variable = va) | |
R1.pack() | |
y.append(R1) | |
seeders[o] = re.sub("[^0-9]","", seeders[o]) | |
leachers[o] = re.sub("[^0-9]","", leachers[o]) | |
try: | |
sizelist[o] = float(sizelist[o]) | |
except ValueError: | |
sizelist[o] = 0 | |
if float(sizelist[o]) == 0: | |
mlabel = Label(gui, text = " Seeds-{} Leachers-{} Size- No Data".format(seeders[o], leachers[o])) | |
mlabel.pack() | |
elif float(sizelist[o]) < 50.0: | |
mlabel = Label(gui, text = " Seeds-{} Leachers-{} Size-{}Gb".format(seeders[o], leachers[o], sizelist[o])) | |
mlabel.pack() | |
elif float(sizelist[o]) > 50.0: | |
mlabel = Label(gui, text = " Seeds-{} Leachers-{} Size-{}Mb".format(seeders[o], leachers[o], sizelist[o])) | |
mlabel.pack() | |
else: | |
mlabel = Label(gui, text = " Seeds-{} Leachers-{} Size-No Data Available".format(seeders[o], leachers[o])) | |
mlabel.pack() | |
m.append(mlabel) | |
o += 1 | |
butframe = Frame(gui) | |
mbutton2 = Button(butframe, text = "Chromecast", command = cast) | |
mbutton2.pack(side=LEFT, pady=10) | |
mbutton1 = Button(butframe, text = "VLC", command = player) | |
mbutton1.pack(side=LEFT, padx=10) | |
mbutton4 = Button(butframe, text = "MPC", command = mpc) | |
mbutton4.pack(side=LEFT) | |
mbutton3 = Button(butframe, text = "Torrent Page", command = website) | |
mbutton3.pack(side=LEFT, padx=10) | |
butframe.pack(side=BOTTOM) | |
global check1 | |
global count | |
global mlabel1 | |
global mbutton1 | |
global mbutton2 | |
global butframe | |
global mbutton4 | |
if count > 0: | |
for x in y: | |
x.pack_forget() | |
x.destroy() | |
for x in m: | |
x.pack_forget() | |
x.destroy() | |
mbutton4.pack_forget() | |
butframe.pack_forget() | |
mlabel1.pack_forget() | |
mbutton1.pack_forget() | |
mbutton2.pack_forget() | |
mbutton3.pack_forget() | |
mlabel = Label(gui, text = 'What would you like to watch?').pack() | |
mentry = Entry(gui, textvariable = check1, width = 25) | |
mentry.pack() | |
mbutton = Button(gui, text = 'Search',command = list1) | |
mbutton.pack(pady = 3) | |
gui.bind('<Return>', list1) | |
gui.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment