From 9bb2f864e01c8b7e1c9481ca043da6aaacdfaa91 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 28 Nov 2019 11:32:58 +1100 Subject: [PATCH] Use headless mode (don't allow manual login) --- spectur_live_view.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spectur_live_view.py b/spectur_live_view.py index dd5d9a7..390b99a 100644 --- a/spectur_live_view.py +++ b/spectur_live_view.py @@ -23,6 +23,7 @@ URL = 'https://camera.uwatchit.com.au/UWatchitWebV2/User/LiveView#' OUTPUT_DIR = 'images' TIMEZONE = 'Australia/Sydney' WAIT_TIME = 0.1 +RECORDING_DURATION = 120 username = '' password = '' @@ -35,7 +36,7 @@ def start_session(): """ # Start webdriver options = Options() - options.headless = False + options.headless = True driver = webdriver.Firefox(options=options) return driver @@ -75,13 +76,11 @@ def login(driver): pss.send_keys(credentials['PASSWORD']) btn.click() except FileNotFoundError: - # Wait for user to log in manually - while True: - try: - driver.find_element_by_id('UserName') - time.sleep(1) - except NoSuchElementException: - break + msg = f"""Provide spectur login details either: + 1. In the header of this script; or + 2. In the file {credential_path}. + """ + ValueError(msg) # Extract cookies session = requests.Session()