snapshot: better error on empty url

This commit is contained in:
Koushik Dutta
2022-03-02 11:32:01 -08:00
parent 61f320e72e
commit a1ab6502d8
3 changed files with 18 additions and 12 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/snapshot",
"version": "0.0.12",
"version": "0.0.13",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/snapshot",
"version": "0.0.12",
"version": "0.0.13",
"dependencies": {
"@koush/axios-digest-auth": "^0.8.5",
"@types/node": "^16.6.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/snapshot",
"version": "0.0.12",
"version": "0.0.13",
"description": "Snapshot Plugin for Scrypted",
"scripts": {
"prepublishOnly": "NODE_ENV=production scrypted-webpack",

View File

@@ -100,17 +100,23 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
}
if (!takePicture) {
if (!this.storageSettings.values.snapshotUrl && this.mixinDeviceInterfaces.includes(ScryptedInterface.Camera)) {
takePicture = async () => {
// if operating in full resolution mode, nuke any picture options containing
// the requested dimensions that are sent.
if (this.storageSettings.values.snapshotResolution === 'Full Resolution' && options)
options.picture = undefined;
return this.mixinDevice.takePicture(options).then(mo => mediaManager.convertMediaObjectToBuffer(mo, 'image/jpeg'))
};
if (!this.storageSettings.values.snapshotUrl) {
if (this.mixinDeviceInterfaces.includes(ScryptedInterface.Camera)) {
takePicture = async () => {
// if operating in full resolution mode, nuke any picture options containing
// the requested dimensions that are sent.
if (this.storageSettings.values.snapshotResolution === 'Full Resolution' && options)
options.picture = undefined;
return this.mixinDevice.takePicture(options).then(mo => mediaManager.convertMediaObjectToBuffer(mo, 'image/jpeg'))
};
}
else {
takePicture = () => {
throw new Error('Snapshot Unavailable (snapshotUrl empty, and prebuffer not available or enabled)');
}
}
}
else {
if (!this.axiosClient) {
let username: string;
let password: string;