Merge pull request #80 from fronzbot/v0.8.3

V0.8.3
This commit is contained in:
Kevin Fronczak
2018-09-24 22:31:12 -04:00
committed by GitHub
3 changed files with 13 additions and 10 deletions
+7 -4
View File
@@ -196,8 +196,8 @@ class BlinkCamera():
self._status = values['active']
self.clip = "{}{}".format(
self.urls.base_url, values['video'])
thumb_from_clip = self.clip[0:-4]
self.thumbnail = "{}.jpg".format(thumb_from_clip)
self.thumbnail = "{}{}.jpg".format(
self.urls.base_url, values['thumbnail'])
self._battery_string = values['battery']
self.notifications = values['notifications']
@@ -245,10 +245,9 @@ class BlinkCamera():
for element in response:
try:
if str(element['device_id']) == self.id:
clip = element['video']
self.thumbnail = (
"{}{}.jpg".format(
self.urls.base_url, clip[0:-4])
self.urls.base_url, element['thumbnail'])
)
return self.thumbnail
except KeyError:
@@ -259,11 +258,15 @@ class BlinkCamera():
"""Write image to file."""
_LOGGER.debug("Writing image from %s to %s", self.name, path)
thumb = self.image_refresh()
if not thumb:
thumb = self.thumbnail
response = _request(self.blink, url=thumb, headers=self.header,
reqtype='get', stream=True, json_resp=False)
if response.status_code == 200:
with open(path, 'wb') as imgfile:
copyfileobj(response.raw, imgfile)
else:
print(response)
def video_to_file(self, path):
"""Write video to file."""
+1 -1
View File
@@ -4,7 +4,7 @@ import os
MAJOR_VERSION = 0
MINOR_VERSION = 8
PATCH_VERSION = 2
PATCH_VERSION = 3
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
+5 -5
View File
@@ -39,7 +39,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
'name': 'foobar',
'armed': False,
'active': 'disarmed',
'thumbnail': '/test/clip/clip.jpg',
'thumbnail': '/test/image',
'video': '/test/clip/clip.mp4',
'temp': 70,
'battery': 3,
@@ -76,7 +76,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
self.assertEqual(camera.armed, False)
self.assertEqual(
camera.thumbnail,
"https://rest.test.{}/test/clip/clip.jpg".format(BLINK_URL)
"https://rest.test.{}/test/image.jpg".format(BLINK_URL)
)
self.assertEqual(
camera.clip,
@@ -93,7 +93,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
camera_config = self.camera_config
camera_config['active'] = 'armed'
camera_config['thumbnail'] = '/test2/clip.jpg'
camera_config['thumbnail'] = '/test2/image'
camera_config['video'] = '/test2/clip.mp4'
camera_config['temp'] = 60
camera_config['battery'] = 0
@@ -104,7 +104,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
self.assertEqual(camera.armed, True)
self.assertEqual(
camera.thumbnail,
"https://rest.test.{}/test2/clip.jpg".format(BLINK_URL)
"https://rest.test.{}/test2/image.jpg".format(BLINK_URL)
)
self.assertEqual(
camera.clip,
@@ -143,7 +143,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
self.assertEqual(camera_attr['armed'], False)
self.assertEqual(
camera_attr['thumbnail'],
"https://rest.test.{}/test/clip/clip.jpg".format(BLINK_URL)
"https://rest.test.{}/test/image.jpg".format(BLINK_URL)
)
self.assertEqual(
camera_attr['video'],