diff --git a/spectur_live_view.py b/spectur_live_view.py index b5e26ee..c0728b8 100644 --- a/spectur_live_view.py +++ b/spectur_live_view.py @@ -18,12 +18,12 @@ from selenium.common.exceptions import (NoSuchElementException, WebDriverException) CAM_ID = 0 -USERNAME = '' -PASSWORD = '' URL = 'https://camera.uwatchit.com.au/UWatchitWebV2/User/LiveView#' OUTPUT_DIR = 'images' TIMEZONE = 'Australia/Sydney' WAIT_TIME = 0.1 +username = '' +password = '' def start_session(): @@ -52,15 +52,25 @@ def login(driver): driver.get(URL) - # Get login fields - usr = driver.find_element_by_id('UserName') - pss = driver.find_element_by_id('Password') - btn = driver.find_element_by_id('submitlogin') - - # Input login details - usr.send_keys(USERNAME) - pss.send_keys(PASSWORD) - btn.click() + # Login automatically if details provided + if username and password: + # Get login fields + usr = driver.find_element_by_id('UserName') + pss = driver.find_element_by_id('Password') + btn = driver.find_element_by_id('submitlogin') + + # Input login details + usr.send_keys(username) + pss.send_keys(password) + btn.click() + else: + # Wait for user to log in manually + while True: + try: + print(driver.find_element_by_id('UserName')) + time.sleep(1) + except NoSuchElementException: + break # Extract cookies session = requests.Session()