1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- from setup import *
- programname = 'WATCHLIVE'
- userdatadir, userlist, config, minimize, approval = setup(programname)
- def execute():
- try:
- liveurl = config[programname]['liveurl']
- watchtime = int(config[programname]['watchtime'])
- print("Live URL is "+ liveurl)
- print("Watching video for "+ str(watchtime) + " seconds")
- except:
- print("Invalid settings. Please check settings and try again.")
- tsleep(5)
- return 0
- if 'facebook.com' in liveurl:
- tsleep(5)
- driver, selecteduser=restart_browser(userdatadir, userlist)
- # ANY RETURN 0 AFTER THIS POINT WILL REQUIRE DRIVER.QUIT TO BE CALLED FIRST BEFORE PROCEEDING, TO PREVENT POSSIBLE MEMORY LEAK
- if minimize == 1:
- driver.minimize_window()
- print(selecteduser)
- try:
- driver.get(liveurl)
- except:
- #traceback.print_exc()
- print("Can't get URL or invalid URL. Please check the URL and try again.")
- tsleep(5)
- driver.quit()
- return 0
- # CHECK IF YOU ARE LOGGED IN
- if "login" in driver.current_url:
- print("Not logged in. Please make sure you are logged in.")
- tsleep(5)
- driver.quit()
- return 0
-
- # YOU HAVE LOGGED IN AT THIS POINT -- MAIN PROGRAM EXECUTION STARTS HERE
- elmt = driver.find_element(By.XPATH, "//*[contains(@class,'xl56j7k x5yr21d x78zum5 x6s0dn4')]")
- tsleep(5)
- if elmt:
- try:
- webdriver.ActionChains(driver).move_to_element(elmt).perform()
- webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
- print("Watching live video")
- tsleep(watchtime)
- print("Completed")
- except KeyboardInterrupt:
- print("Interrupted")
- except:
- print("Video error. Please try another video.")
- print("Program has completed execution")
- else:
- print("Can't get URL or invalid URL. Please check the URL and try again.")
-
- tsleep(5)
- driver.quit()
-
- if approval == 1:
- execute()
|