Advertisement
Guest User

Online model notifier for MFC and Chaturbate

a guest
Feb 7th, 2016
2,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.01 KB | None | 0 0
  1. # "Model online" notifier for Chaturbate and MyFreeCams
  2. # Using Python 2.7.x
  3. # Keep the program open and it will check for models every 5 minutes
  4. # Made in January 2016 by qolop, feel free to reuse
  5.  
  6. from urllib2 import urlopen
  7. import webbrowser
  8. import time
  9. import Tkinter
  10. import tkMessageBox
  11.  
  12. cb_models = ['sassyhelen', 'pik4pik4', 'myalennon', 'notyourmomandad',
  13.              'siswet19', 'little_mischief', 'cherrycrush', 'princesslexi__',
  14.              'willowswonderland', 'eeeveee', 'jadeasani']
  15.  
  16. mfc_models = ['xwildthingx', 'lovelykittie', 'jollieann', 'vandaorchid',
  17.               'amberhahn', 'illicit69', 'brina', 'klutzy_kline', 'itscleo']
  18.  
  19. # chaturbate model parse is ezpz, models are listed in source code of homepage
  20. online_rn_cb = [] # list of models currently online on Chaturbate.com
  21. online_rn_mfc = [] # list of models currently online on MyFreecams.com
  22.  
  23. def accesscam(model):
  24.     '''Open model's webcam in default browser.'''
  25.     print "Opening {}'s webcam in browser".format(model)
  26.     if model in mfc_models:
  27.         webbrowser.open_new_tab("http://www.myfreecams.com/#{}".format(model))
  28.     else:
  29.         webbrowser.open_new_tab(("https://chaturbate.com/{}".format(model)))
  30.  
  31. def parsemodels():
  32.     '''Find which models are currently online.'''
  33.     print "Parsing Chaturbate models."
  34.     k = urlopen("https://chaturbate.com").read() # get CB homepage source code
  35.     for model in cb_models:
  36.         if k.find(model) > -1: # any number bigger than -1 = string found
  37.             if model not in online_rn_cb:
  38.                 print "{} just came online!".format(model)
  39.                 online_rn_cb.append(model)
  40.                 askuser(model)
  41.             else:
  42.                 print "{} is still online.".format(model)
  43.         else:
  44.             try:
  45.                 online_rn_cb.remove(model) # remove offline model from online list
  46.                 print "{} just went offline.".format(model)
  47.             except ValueError:
  48.                 pass
  49.     print "Parsing MyFreeCams models."
  50.     # There probably is a faster way to parse MFC models, though it would be trickier
  51.     for model in mfc_models:
  52.         p = urlopen("http://profiles.myfreecams.com/{}".format(model)).read()
  53.         if p.find('Online"}') > -1:
  54.             if model not in online_rn_mfc: # if it is not known that model is online
  55.                 print "{} just came online!".format(model)
  56.                 online_rn_mfc.append(model)
  57.                 askuser(model)
  58.             else:
  59.                 print "{} is still online".format(model)
  60.         else: # if models is offline
  61.             try:
  62.                 online_rn_mfc.remove(model) # removes offline models from online list
  63.                 print "{} just went offline.".format(model)
  64.             except ValueError: # if no offline models in online list,
  65.                 pass # continue executing program
  66.  
  67. def askuser(model):
  68.     '''Pop up message box asking user if they want to open the cam'''
  69.     print "Asking user whether to open {}'s webcam.".format(model)
  70.     root = Tkinter.Tk()
  71.     root.withdraw()
  72.     # use tkinter to ask inter whether to open cam outside terminal
  73.     result = tkMessageBox.askquestion("Model online", "Open {}'s cam?".format(model), icon='warning')
  74.     if result == 'yes':
  75.         B1 = Tkinter.Button(root, text="Open in browser", command=accesscam(model))
  76.         B1.pack()
  77.     else:
  78.         print "You chose not to open {}'s webcam.".format(model)
  79.  
  80. if __name__ == '__main__':
  81.     print "Initiated program."
  82.     x = 0
  83.     while x > -1: # infinite while loop to continously run program
  84.         t0 = time.time()
  85.         x += 1 # keep track of how many times program is run
  86.         parsemodels()
  87.         if online_rn_cb == [] and online_rn_mfc == []:
  88.             print "No models are currently online. :("
  89.         t1 = time.time()
  90.         t = t1 - t0
  91.         print "Checked {} times in {} seconds.".format(x, t)
  92.         print "Waiting 5 minutes to reparse online model list."
  93.         time.sleep(300) # waits 300 seconds (5min) to check models again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement