import random, sys, httplib2, win32clipboard, webbrowser, time, zipfile, os, urllib, requests
from copy import deepcopy
from bs4 import SoupStrainer
from bs4 import BeautifulSoup
from urllib2 import Request
from urllib2 import urlopen
from tqdm import tqdm
from Tkinter import *
#When I wrote this, only God and I knew what I was writing
#Now only God knows
#
#added GUI -todes
#(toads_tf also knows)
def download_zip(page,path):
data = "
http://sizzlingstv.s3.amazonaws.com/stv/"+ page[-6:] +".zip"
filename = page[-6:] + ".zip"
try:
urllib.urlretrieve (data, filename)
print data
except:
print("No zip file was found, ending program...")
os.remove(filename)
time.sleep(5)
exit()
for i in tqdm(range(100)):
time.sleep(0.02)
try:
zip_ref = zipfile.ZipFile(filename, 'r')
zip_ref.extractall(path)
zip_ref.close()
os.remove(filename)
except Exception as e:
print str(e)
gameVar = StringVar()
top = Toplevel()
top.title('Error')
msg = Message(top,text="Something went wrong while exporting. Try putting your Team Fortress 2\\tf folder path here, but with double slashes. (\\\, not \)")
msg.pack()
gameDir = Entry(top,textvariable=gameVar,width=20)
gameDir.pack()
changeBtn = Button(top,text='Retry',command=lambda:download_zip(link.get(),gameVar.get()),width=7)
changeBtn.pack()
TOPP = Toplevel()
TOPP.title('Complete!')
mensaje= Message(TOPP,text=filename + " From " + data + " has been downloaded and extracted.")
mensaje.pack()
time.sleep(5)
window = Tk()
window.title('Sizzlingstats Downloader')
link = StringVar()
info = Label(window,text='Please copy the .ss link below:')
info.pack()
linkBox = Entry(window,textvariable=link,width=30)
linkBox.pack()
goBtn = Button(window,text='Go',command=lambda:download_zip(link.get(),"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Team Fortress 2\\tf"),width=10)
goBtn.pack()
window.mainloop()