From 87e535c56a517aa6a8bab54ea917d7591849c65a Mon Sep 17 00:00:00 2001 From: tyr84 Date: Wed, 11 Oct 2023 15:12:30 +0200 Subject: [PATCH] Add option for ecdh curve and backup at runtime --- README.md | 2 ++ main.py | 24 +++++++++++++++++++----- requirements.txt | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a50f1cd..76ae076 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ MQTT_TOPIC_MOTION: motion events will be published to this topic. (default: arlo MQTT_RECONNECT_INTERVAL: Wait this amount before retrying connection to broker (in seconds) (default: 5) STATUS_INTERVAL: Time between published status messages (in seconds) (default: 120) DEBUG: True enables full debug (default: False) +PYAARLO_ECDH_CURVE: ecdh Curve used to bypass Cloudflare. (default determined by cloudscraper). Try `secp384r1` if struggling with login. +PYAARLO_BACKEND: Pyaarlo backend. (default determined by pyaarlo). Options are `mqtt` and `sse`. ``` ### Running ``` diff --git a/main.py b/main.py index a69fa69..e4281de 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,8 @@ MOTION_TIMEOUT = config('MOTION_TIMEOUT', default=60, cast=int) STATUS_INTERVAL = config('STATUS_INTERVAL', default=120, cast=int) DEBUG = config('DEBUG', default=False, cast=bool) +PYAARLO_ECDH_CURVE=config('PYAARLO_ECDH_CURVE', default=None) +PYAARLO_BACKEND=config('PYAARLO_BACKEND', default=None) # Initialize logging logging.basicConfig( @@ -28,11 +30,23 @@ async def main(): # login to arlo with 2FA - arlo = pyaarlo.PyArlo( - username=ARLO_USER, password=ARLO_PASS, - tfa_source='imap', tfa_type='email', tfa_host=IMAP_HOST, - tfa_username=IMAP_USER, tfa_password=IMAP_PASS, backend='sse' - ) + arlo_args = { + 'username': ARLO_USER, + 'password': ARLO_PASS, + 'tfa_source': 'imap', + 'tfa_type': 'email', + 'tfa_host': IMAP_HOST, + 'tfa_username': IMAP_USER, + 'tfa_password': IMAP_PASS + } + + if PYAARLO_ECDH_CURVE: + arlo_args['ecdh_curve'] = PYAARLO_ECDH_CURVE + + if PYAARLO_BACKEND: + arlo_args['backend'] = PYAARLO_BACKEND + + arlo = pyaarlo.PyArlo(**arlo_args) # Initialize and start cameras cameras = [Camera( diff --git a/requirements.txt b/requirements.txt index 07e99a4..24c83e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -git+https://github.com/twrecked/pyaarlo +git+https://github.com/tyr84/pyaarlo@ecdh_curve python-decouple asyncio-mqtt aiostream