Skip to content

Commit caef1ee

Browse files
committed
fix: getVideos should use api v1
1 parent 3804eb5 commit caef1ee

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/blink.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ module.exports = class Blink {
273273
});
274274
}
275275

276-
getVideos() {
276+
getVideos(page = 0, since = new Date(2008)) { // Blink was founded in 2009
277277
return new Promise((resolve, reject) => {
278278
request({
279-
url: this.urls.video_url,
279+
url: `${this.urls.video_url}?since=${since.toISOString()}&page=${page}`,
280280
headers: this._auth_header,
281281
json: true
282282
}, (err, response, body) => {
@@ -343,7 +343,7 @@ module.exports = class Blink {
343343
'Host': this._host,
344344
'TOKEN_AUTH': this._token
345345
};
346-
this.urls = new BlinkURLHandler(this._region_id);
346+
this.urls = new BlinkURLHandler(this._account_id, this._region_id);
347347
}
348348
_getAuthToken(repeats = 0) {
349349
return new Promise((resolve, reject) => {
@@ -385,7 +385,7 @@ module.exports = class Blink {
385385
'TOKEN_AUTH': this._token
386386
};
387387

388-
this.urls = new BlinkURLHandler(this._region_id);
388+
this.urls = new BlinkURLHandler(this._account_id, this._region_id);
389389
resolve(true);
390390
};
391391

@@ -484,7 +484,7 @@ module.exports = class Blink {
484484
}
485485

486486
that._account_id = that._networks[0].account_id;
487-
that.urls = new BlinkURLHandler(that.regionId);
487+
that.urls = new BlinkURLHandler(that.accountId, that.regionId);
488488
return resolve(that);
489489
}
490490
});

lib/blink_camera.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ module.exports = class BlinkCamera {
251251
fetchVideoData() {
252252
return new Promise((resolve, reject) => {
253253
request({
254-
url: this.thumbnail,
254+
url: this.clip,
255255
headers: this._header,
256256
encoding: null
257257
}, (err, response, body) => {

lib/blink_url_handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
*/
44

55
module.exports = class BlinkURLHandler {
6-
constructor(region_id) {
6+
constructor(account_id, region_id) {
77
this.base_url = 'https://rest.' + region_id + '.' + BLINK_URL;
88
this.event_url = this.base_url + '/events/network/';
99
this.network_url = this.base_url + '/network/';
1010
this.networks_url = this.base_url + '/networks';
11-
this.video_url = this.base_url + '/api/v2/videos';
11+
this.video_url = this.base_url + `/api/v1/accounts/${account_id}/media/changed`;
1212
this.home_url = this.base_url + '/homescreen';
1313
}
1414
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-blink-security",
3-
"version": "4.1.2",
3+
"version": "4.1.3",
44
"description": "A NodeJS module for the Blink Security Camera System",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)