Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # "Model online" notifier for Chaturbate and MyFreeCams
- # Using Python 2.7.x
- # Keep the program open and it will check for models every 5 minutes
- # Made in January 2016 by qolop, feel free to reuse
- from urllib2 import urlopen
- import webbrowser
- import time
- import Tkinter
- import tkMessageBox
- cb_models = ['sassyhelen', 'pik4pik4', 'myalennon', 'notyourmomandad',
- 'siswet19', 'little_mischief', 'cherrycrush', 'princesslexi__',
- 'willowswonderland', 'eeeveee', 'jadeasani']
- mfc_models = ['xwildthingx', 'lovelykittie', 'jollieann', 'vandaorchid',
- 'amberhahn', 'illicit69', 'brina', 'klutzy_kline', 'itscleo']
- # chaturbate model parse is ezpz, models are listed in source code of homepage
- online_rn_cb = [] # list of models currently online on Chaturbate.com
- online_rn_mfc = [] # list of models currently online on MyFreecams.com
- def accesscam(model):
- '''Open model's webcam in default browser.'''
- print "Opening {}'s webcam in browser".format(model)
- if model in mfc_models:
- webbrowser.open_new_tab("http://www.myfreecams.com/#{}".format(model))
- else:
- webbrowser.open_new_tab(("https://chaturbate.com/{}".format(model)))
- def parsemodels():
- '''Find which models are currently online.'''
- print "Parsing Chaturbate models."
- k = urlopen("https://chaturbate.com").read() # get CB homepage source code
- for model in cb_models:
- if k.find(model) > -1: # any number bigger than -1 = string found
- if model not in online_rn_cb:
- print "{} just came online!".format(model)
- online_rn_cb.append(model)
- askuser(model)
- else:
- print "{} is still online.".format(model)
- else:
- try:
- online_rn_cb.remove(model) # remove offline model from online list
- print "{} just went offline.".format(model)
- except ValueError:
- pass
- print "Parsing MyFreeCams models."
- # There probably is a faster way to parse MFC models, though it would be trickier
- for model in mfc_models:
- p = urlopen("http://profiles.myfreecams.com/{}".format(model)).read()
- if p.find('Online"}') > -1:
- if model not in online_rn_mfc: # if it is not known that model is online
- print "{} just came online!".format(model)
- online_rn_mfc.append(model)
- askuser(model)
- else:
- print "{} is still online".format(model)
- else: # if models is offline
- try:
- online_rn_mfc.remove(model) # removes offline models from online list
- print "{} just went offline.".format(model)
- except ValueError: # if no offline models in online list,
- pass # continue executing program
- def askuser(model):
- '''Pop up message box asking user if they want to open the cam'''
- print "Asking user whether to open {}'s webcam.".format(model)
- root = Tkinter.Tk()
- root.withdraw()
- # use tkinter to ask inter whether to open cam outside terminal
- result = tkMessageBox.askquestion("Model online", "Open {}'s cam?".format(model), icon='warning')
- if result == 'yes':
- B1 = Tkinter.Button(root, text="Open in browser", command=accesscam(model))
- B1.pack()
- else:
- print "You chose not to open {}'s webcam.".format(model)
- if __name__ == '__main__':
- print "Initiated program."
- x = 0
- while x > -1: # infinite while loop to continously run program
- t0 = time.time()
- x += 1 # keep track of how many times program is run
- parsemodels()
- if online_rn_cb == [] and online_rn_mfc == []:
- print "No models are currently online. :("
- t1 = time.time()
- t = t1 - t0
- print "Checked {} times in {} seconds.".format(x, t)
- print "Waiting 5 minutes to reparse online model list."
- time.sleep(300) # waits 300 seconds (5min) to check models again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement