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

Commit

Permalink
Merge branch 'master' into issue_103_retrieving_media_doorbell
Browse files Browse the repository at this point in the history
  • Loading branch information
tchellomello authored Dec 6, 2020
2 parents 460a0e3 + c1703d8 commit d8e551d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ matrix:
env: TOXENV=py36
- python: "3.7"
env: TOXENV=py37
dist: xenial
sudo: true
- python: "3.4.2"
env: TOXENV=lint
install: pip install -U tox coveralls
Expand Down
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
7 changes: 7 additions & 0 deletions pyarlo/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,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
10 changes: 9 additions & 1 deletion pyarlo/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# coding: utf-8
"""Implementation of Arlo utils."""
import logging
import time
from datetime import datetime as dt
import requests

_LOGGER = logging.getLogger(__name__)


def to_datetime(timestamp):
"""Return datetime object from timestamp."""
Expand All @@ -19,7 +22,12 @@ def pretty_timestamp(timestamp, date_format='%a-%m_%d_%y:%H:%M:%S'):

def http_get(url, filename=None):
"""Download HTTP data."""
ret = requests.get(url)
try:
ret = requests.get(url)
except requests.exceptions.SSLError as error:
_LOGGER.error(error)
return False

if ret.status_code != 200:
return False

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}
}

1 comment on commit d8e551d

@rajneeshraina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very new to Python. How do I get the videos downloaded. I downloded the code base and tried to run the code as mentioned from command prompt. But nothing seems to be happening
any thoughts?

Please sign in to comment.