mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 09:12:03 +00:00
unifi-protect: aspect ratio fixup
This commit is contained in:
4
plugins/unifi-protect/package-lock.json
generated
4
plugins/unifi-protect/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.44",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.44",
|
||||
"license": "Apache",
|
||||
"dependencies": {
|
||||
"@types/ws": "^7.4.7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.44",
|
||||
"description": "Unifi Protect Plugin for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -80,8 +80,19 @@ class UnifiCamera extends ScryptedDeviceBase implements Camera, VideoCamera, Mot
|
||||
|
||||
async getSnapshot(options?: PictureOptions): Promise<Buffer> {
|
||||
let size = '';
|
||||
if (options?.picture?.width && options?.picture?.height)
|
||||
size = `&w=${options.picture.width}&h=${options.picture.height}`;
|
||||
try {
|
||||
if (options?.picture?.width && options?.picture?.height) {
|
||||
const camera = this.findCamera();
|
||||
const mainChannel = camera.channels[0];
|
||||
const w = options.picture.width;
|
||||
const h = Math.round((mainChannel.height / mainChannel.width) * w);
|
||||
|
||||
size = `&w=${w}&h=${h}`;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
}
|
||||
const url = `https://${this.protect.getSetting('ip')}/proxy/protect/api/cameras/${this.nativeId}/snapshot?ts=${Date.now()}${size}`
|
||||
|
||||
const response = await this.protect.api.loginFetch(url);
|
||||
|
||||
Reference in New Issue
Block a user