Skip to content

Commit 37fc047

Browse files
authored
Merge pull request #80 from fronzbot/v0.8.3
V0.8.3
2 parents 5319714 + 6343965 commit 37fc047

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

blinkpy/blinkpy.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ def update(self, values):
196196
self._status = values['active']
197197
self.clip = "{}{}".format(
198198
self.urls.base_url, values['video'])
199-
thumb_from_clip = self.clip[0:-4]
200-
self.thumbnail = "{}.jpg".format(thumb_from_clip)
199+
self.thumbnail = "{}{}.jpg".format(
200+
self.urls.base_url, values['thumbnail'])
201201
self._battery_string = values['battery']
202202
self.notifications = values['notifications']
203203

@@ -245,10 +245,9 @@ def image_refresh(self):
245245
for element in response:
246246
try:
247247
if str(element['device_id']) == self.id:
248-
clip = element['video']
249248
self.thumbnail = (
250249
"{}{}.jpg".format(
251-
self.urls.base_url, clip[0:-4])
250+
self.urls.base_url, element['thumbnail'])
252251
)
253252
return self.thumbnail
254253
except KeyError:
@@ -259,11 +258,15 @@ def image_to_file(self, path):
259258
"""Write image to file."""
260259
_LOGGER.debug("Writing image from %s to %s", self.name, path)
261260
thumb = self.image_refresh()
261+
if not thumb:
262+
thumb = self.thumbnail
262263
response = _request(self.blink, url=thumb, headers=self.header,
263264
reqtype='get', stream=True, json_resp=False)
264265
if response.status_code == 200:
265266
with open(path, 'wb') as imgfile:
266267
copyfileobj(response.raw, imgfile)
268+
else:
269+
print(response)
267270

268271
def video_to_file(self, path):
269272
"""Write video to file."""

blinkpy/helpers/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
MAJOR_VERSION = 0
66
MINOR_VERSION = 8
7-
PATCH_VERSION = 2
7+
PATCH_VERSION = 3
88

99
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
1010

tests/test_blink_cameras.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def setUp(self):
3939
'name': 'foobar',
4040
'armed': False,
4141
'active': 'disarmed',
42-
'thumbnail': '/test/clip/clip.jpg',
42+
'thumbnail': '/test/image',
4343
'video': '/test/clip/clip.mp4',
4444
'temp': 70,
4545
'battery': 3,
@@ -76,7 +76,7 @@ def test_camera_properties(self, mock_get, mock_post, mock_cfg):
7676
self.assertEqual(camera.armed, False)
7777
self.assertEqual(
7878
camera.thumbnail,
79-
"https://rest.test.{}/test/clip/clip.jpg".format(BLINK_URL)
79+
"https://rest.test.{}/test/image.jpg".format(BLINK_URL)
8080
)
8181
self.assertEqual(
8282
camera.clip,
@@ -93,7 +93,7 @@ def test_camera_properties(self, mock_get, mock_post, mock_cfg):
9393

9494
camera_config = self.camera_config
9595
camera_config['active'] = 'armed'
96-
camera_config['thumbnail'] = '/test2/clip.jpg'
96+
camera_config['thumbnail'] = '/test2/image'
9797
camera_config['video'] = '/test2/clip.mp4'
9898
camera_config['temp'] = 60
9999
camera_config['battery'] = 0
@@ -104,7 +104,7 @@ def test_camera_properties(self, mock_get, mock_post, mock_cfg):
104104
self.assertEqual(camera.armed, True)
105105
self.assertEqual(
106106
camera.thumbnail,
107-
"https://rest.test.{}/test2/clip.jpg".format(BLINK_URL)
107+
"https://rest.test.{}/test2/image.jpg".format(BLINK_URL)
108108
)
109109
self.assertEqual(
110110
camera.clip,
@@ -143,7 +143,7 @@ def test_camera_attributes(self, mock_cfg):
143143
self.assertEqual(camera_attr['armed'], False)
144144
self.assertEqual(
145145
camera_attr['thumbnail'],
146-
"https://rest.test.{}/test/clip/clip.jpg".format(BLINK_URL)
146+
"https://rest.test.{}/test/image.jpg".format(BLINK_URL)
147147
)
148148
self.assertEqual(
149149
camera_attr['video'],

0 commit comments

Comments
 (0)