From 675e714aaecd2e5c8f8a6c0db5d8f63afc139d13 Mon Sep 17 00:00:00 2001 From: Mark Coombes Date: Mon, 28 Jan 2019 10:58:21 -0500 Subject: [PATCH] v0.3.0 (#2) Add "live" parameter to certain API requests. --- README.md | 2 +- pykuna/camera.py | 14 ++++++++++++-- pykuna/kuna.py | 5 ++--- setup.py | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7128cbf..0271abf 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Where: - `USERNAME` is the email address you use for the Kuna app; and, - `PASSWORD` is your password for the Kuna app. -After authenticating, populate a list of all cameras in the Kuna account by calling the `update()` method on the API object: +After authenticating, populate (or refresh) a list of all cameras in the Kuna account by calling the `update()` method on the API object: ```python kuna.update() diff --git a/pykuna/camera.py b/pykuna/camera.py index b7296da..6d6307d 100644 --- a/pykuna/camera.py +++ b/pykuna/camera.py @@ -207,22 +207,32 @@ def custom_messages(self): def update(self): """Update device info from the Kuna cloud service.""" + params = { + 'live': 1 + } + result = self._request( 'get', '{}/{}/'.format(ENDPOINT_CAMERA, - self.serial_number) + self.serial_number), + params=params ) self._raw = result def get_thumbnail(self): """Retrieve a thumbnail image for the device.""" + params = { + 'live': 1 + } + result = self._request( 'get', '{}/{}/{}/'.format(ENDPOINT_CAMERA, self.serial_number, ENDPOINT_THUMBNAIL), - thumbnail=True + thumbnail=True, + params=params ) return result diff --git a/pykuna/kuna.py b/pykuna/kuna.py index a4517e4..267b44c 100644 --- a/pykuna/kuna.py +++ b/pykuna/kuna.py @@ -40,7 +40,6 @@ def authenticate(self): def update(self): """Refresh the list of all cameras in the Kuna account.""" - result = self._request('get', CAMERAS_ENDPOINT) cameras = [] @@ -50,7 +49,7 @@ def update(self): self.cameras = cameras - def _request(self, method, path, json=None, thumbnail=False): + def _request(self, method, path, json=None, params=None, thumbnail=False): """Make an API request""" import requests from requests.exceptions import HTTPError, Timeout @@ -74,7 +73,7 @@ def _request(self, method, path, json=None, thumbnail=False): headers['User-Agent'] = USER_AGENT_THUMBNAIL try: - result = req(url, headers=headers, json=json, timeout=3) + result = req(url, headers=headers, json=json, params=params, timeout=3) result.raise_for_status() if thumbnail: diff --git a/setup.py b/setup.py index 0995f81..b1fb36e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setuptools.setup( name="pykuna", - version="0.2.0", + version="0.3.0", author="Mark Coombes", author_email="mark@markcoombes.ca", description="Python3 library for interacting with the Kuna camera mobile API",