Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #119 from tchellomello/version_0_2_4
Browse files Browse the repository at this point in the history
Version 0.2.4
  • Loading branch information
tchellomello authored Dec 6, 2020
2 parents 66acb3d + a33400a commit 242d6db
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
14 changes: 9 additions & 5 deletions pyarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"""Base Python Class file for Netgear Arlo camera module."""
import logging
import requests
import base64

from pyarlo.base_station import ArloBaseStation
from pyarlo.camera import ArloCamera
from pyarlo.media import ArloMediaLibrary
from pyarlo.const import (
BILLING_ENDPOINT, DEVICES_ENDPOINT,
API_URL, BILLING_ENDPOINT, DEVICES_ENDPOINT,
FRIENDS_ENDPOINT, LOGIN_ENDPOINT, PROFILE_ENDPOINT,
PRELOAD_DAYS, RESET_ENDPOINT)

Expand Down Expand Up @@ -69,10 +70,11 @@ def _authenticate(self):
method='POST',
extra_params={
'email': self.__username,
'password': self.__password
})
'password': base64.b64encode(self.__password.encode()).decode()},
extra_headers={
'Referer': API_URL})

if isinstance(data, dict) and data.get('success'):
if isinstance(data, dict) and data.get('meta') and data['meta']['code'] == 200:
data = data.get('data')
self.authenticated = data.get('authenticated')
self.country_code = data.get('countryCode')
Expand All @@ -85,7 +87,9 @@ def _authenticate(self):

def cleanup_headers(self):
"""Reset the headers and params."""
headers = {'Content-Type': 'application/json'}
headers = {
'Content-Type': 'application/json',
'Auth-Version': '2'}
headers['Authorization'] = self.__token
self.__headers = headers
self.__params = {}
Expand Down
28 changes: 14 additions & 14 deletions pyarlo/const.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""Constants used by Python Arlo."""

# API Endpoints
API_URL = "https://arlo.netgear.com/hmsweb"
API_URL = "https://my.arlo.com"

DEVICE_SUPPORT_ENDPOINT = API_URL + "/devicesupport/v2"
SUBSCRIBE_ENDPOINT = API_URL + "/client/subscribe"
UNSUBSCRIBE_ENDPOINT = API_URL + "/client/unsubscribe"
BILLING_ENDPOINT = API_URL + "/users/serviceLevel/v2"
DEVICES_ENDPOINT = API_URL + "/users/devices"
FRIENDS_ENDPOINT = API_URL + "/users/friends"
LIBRARY_ENDPOINT = API_URL + "/users/library"
LOGIN_ENDPOINT = API_URL + "/login/v2"
LOGOUT_ENDPOINT = API_URL + "/logout"
NOTIFY_ENDPOINT = API_URL + "/users/devices/notify/{0}"
PROFILE_ENDPOINT = API_URL + "/users/profile"
DEVICE_SUPPORT_ENDPOINT = API_URL + "/hmsweb/devicesupport/v2"
SUBSCRIBE_ENDPOINT = API_URL + "/hmsweb/client/subscribe"
UNSUBSCRIBE_ENDPOINT = API_URL + "/hmsweb/client/unsubscribe"
BILLING_ENDPOINT = API_URL + "/hmsweb/users/serviceLevel/v2"
DEVICES_ENDPOINT = API_URL + "/hmsweb/users/devices"
FRIENDS_ENDPOINT = API_URL + "/hmsweb/users/friends"
LIBRARY_ENDPOINT = API_URL + "/hmsweb/users/library"
LOGIN_ENDPOINT = "https://ocapi-app.arlo.com/api/auth"
LOGOUT_ENDPOINT = API_URL + "/hmsweb/logout"
NOTIFY_ENDPOINT = API_URL + "/hmsweb/users/devices/notify/{0}"
PROFILE_ENDPOINT = API_URL + "/hmsweb/users/profile"
RESET_ENDPOINT = LIBRARY_ENDPOINT + "/reset"
RESET_CAM_ENDPOINT = RESET_ENDPOINT + "/?uniqueId={0}"
STREAM_ENDPOINT = API_URL + "/users/devices/startStream"
SNAPSHOTS_ENDPOINT = API_URL + "/users/devices/fullFrameSnapshot"
STREAM_ENDPOINT = API_URL + "/hmsweb/users/devices/startStream"
SNAPSHOTS_ENDPOINT = API_URL + "/hmsweb/users/devices/fullFrameSnapshot"

# number of days to preload video
PRELOAD_DAYS = 30
Expand Down
20 changes: 15 additions & 5 deletions pyarlo/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ def load(self, days=PRELOAD_DAYS, only_cameras=None,

for video in data:
# pylint: disable=cell-var-from-loop
srccam = \
list(filter(
lambda cam: cam.device_id == video.get('deviceId'),
all_cameras)
)[0]
try:
srccam = \
list(filter(
lambda cam: cam.device_id == video.get('deviceId'),
all_cameras)
)[0]
except IndexError:
continue

# make sure only_cameras is a list
if only_cameras and \
Expand Down Expand Up @@ -187,6 +190,13 @@ def video_url(self):
return self._attrs.get('presignedContentUrl')
return None

@property
def motion_type(self):
"""Returns the type of motion that triggered the camera. Requires subscription."""
if self._attrs is not None:
return self._attrs.get("objCategory")
return None

def download_thumbnail(self, filename=None):
"""Download JPEG thumbnail.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def readme():
setup(
name='pyarlo',
packages=['pyarlo'],
version='0.2.3',
version='0.2.4',
description='Python Arlo is a library written in Python 2.7/3x ' +
'that exposes the Netgear Arlo cameras as Python objects.',
long_description=readme(),
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/pyarlo_authentication.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
"token": "999999999999",
"userId": "999-123456",
"validEmail": true},
"success": true}
"meta": {"code":200}
}

0 comments on commit 242d6db

Please sign in to comment.