here2share

# Tk_free_iOS_games_by_day_link_automator.py

Nov 4th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.74 KB | None | 0 0
  1. # Tk_free_iOS_games_by_day_link_automator.py
  2.  
  3. try:
  4.     # Python2
  5.     from Tkinter import *
  6.     from urllib2 import urlopen
  7. except ImportError:
  8.     # Python3
  9.     from tkinter import *
  10.     from urllib.request import urlopen
  11. import webbrowser
  12. import time
  13. from datetime import datetime, timedelta
  14.  
  15. html='?????'
  16. max=''
  17. w,h = '160','160'
  18.  
  19. root=Tk()
  20. root.geometry('1280x654+0+0')
  21. root.title('Free iOS Games Link Automator')
  22.  
  23. topFrame=LabelFrame(root,text="",height=600)
  24. topFrame.pack(fill=X)
  25. topFrame.pack_propagate(False)
  26.  
  27. Frame2=LabelFrame(root,height=24,borderwidth=0)
  28. Frame2.pack(fill=X)
  29. Frame2.pack_propagate(False)
  30.  
  31. Frame3=LabelFrame(root,height=30,borderwidth=0)
  32. Frame3.pack(fill=X)
  33. Frame3.pack_propagate(False)
  34.  
  35. ffff=Listbox(topFrame,selectmode=SINGLE)
  36. ffff.pack(fill=BOTH,expand=YES,side=LEFT)
  37. ffff.configure(selectmode=SINGLE)
  38.  
  39. def dblclk(event):
  40.     html=ffff.curselection()
  41.     html=goto[int(html[0])]
  42.     webbrowser.open(html)
  43. ffff.bind("<Double-Button-1>", dblclk)
  44.  
  45. scroll=Scrollbar(topFrame)
  46. scroll.pack(side=RIGHT,fill=Y,expand=NO)
  47.  
  48. scroll.configure(command=ffff.yview)
  49. ffff.configure(yscrollcommand=scroll.set)
  50.  
  51. links=[]
  52. goto=[]
  53.  
  54. #
  55. def update_list(items):
  56.     ffff.delete(0, END)
  57.     for item in items:
  58.         ffff.insert(END,item)
  59.     root.update()
  60. update_list(goto) # None
  61. #
  62. def from_clipboard():
  63.     data = root.clipboard_get()
  64.     url.set(data)
  65.     root.update()
  66.     url_text()
  67. #
  68. def all_links():
  69.     global links, goto, max
  70.     links=[]
  71.     goto=[]
  72.     t=''
  73.     zyear,zmonth,zday=[int(i) for i in max.split('-')]
  74.     i=datetime.now()-datetime(zyear, zmonth, zday)
  75.     i=i.days
  76.     while 1:
  77.         ttt=datetime.now()-timedelta(days=i)
  78.         if ttt.year < 1992 or len(links) > 399: break
  79.         ttt='%s-%s-%s' %(ttt.year,ttt.month,ttt.day)
  80.         tmp=html+'&hl=en&biw='+w+'&bih='+h+'&source=lnt&tbs=cdr%3A1%2Ccd_min%3A'+ttt+'%2Ccd_max%3A'+ttt+'&tbm=isch'
  81.         links.append(ttt)
  82.         goto.append(tmp)
  83.         t+=tmp+'\n\n'
  84.         i+=1
  85.     print t
  86.     print
  87.     goto=goto[1:]
  88.     update_list(links[1:])
  89. #
  90. def url_text():
  91.     global html, max
  92.     html=url.get()
  93.     print html
  94.     if "site%3Aapple.com" not in html:
  95.         html='https://www.google.ca/search?q=site%3Aapple.com+games+free+-%241.99+-%242.99+-%243.99+-%244.99+-%245.99+-%246.99+-%247.99+-%248.99+-%249.99&&hl=en'
  96.     try:
  97.         max=html[html.index('%2Ccd_max%3A')+12:html.index('&tbm=isch')]
  98.     except:pass
  99.     if not max:
  100.         td=datetime.now()
  101.         max='%s-%s-%s' %(td.year,td.month,td.day)
  102.     try:
  103.         html=html[:html.index('&hl=en')]
  104.     except: pass
  105.     all_links()
  106. #
  107.  
  108. btn=Button(Frame2,text="Enter URL",width=16,command=url_text)
  109. btn.pack(side=LEFT)
  110.  
  111. url=StringVar()
  112. ent=Entry(Frame2,width="160",textvariable=url)
  113. ent.pack(side=LEFT)
  114.  
  115. cpb=Button(Frame3,text="Clipboard",width=16,command=from_clipboard)
  116. cpb.pack(side=LEFT)
  117.  
  118. lbl=Label(Frame3)
  119. lbl.pack(side=LEFT)
  120.  
  121. root.mainloop()
Add Comment
Please, Sign In to add comment