diff --git a/plugins/unifi-protect/package-lock.json b/plugins/unifi-protect/package-lock.json index ae5eaad7e..b2ee1dfae 100644 --- a/plugins/unifi-protect/package-lock.json +++ b/plugins/unifi-protect/package-lock.json @@ -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", diff --git a/plugins/unifi-protect/package.json b/plugins/unifi-protect/package.json index 7cb5825b6..5b55f4124 100644 --- a/plugins/unifi-protect/package.json +++ b/plugins/unifi-protect/package.json @@ -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", diff --git a/plugins/unifi-protect/src/main.ts b/plugins/unifi-protect/src/main.ts index 6816f5203..7158723ee 100644 --- a/plugins/unifi-protect/src/main.ts +++ b/plugins/unifi-protect/src/main.ts @@ -80,8 +80,19 @@ class UnifiCamera extends ScryptedDeviceBase implements Camera, VideoCamera, Mot async getSnapshot(options?: PictureOptions): Promise { 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);