Skip to content

Commit

Permalink
v0.3.0 (#2)
Browse files Browse the repository at this point in the history
Add "live" parameter to certain API requests.
  • Loading branch information
marthoc authored Jan 28, 2019
1 parent ad351ee commit 675e714
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 12 additions & 2 deletions pykuna/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pykuna/kuna.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 675e714

Please sign in to comment.