node-red-contrib-hik-media-buffer 1.1.51 → 1.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hik-media-buffer.js +29 -5
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -169,8 +169,33 @@ module.exports = function(RED) {
|
|
|
169
169
|
for (let t of tracks) {
|
|
170
170
|
node.warn(`[STEP 4] Elaborazione traccia ${t.label} (ID: ${t.id})`);
|
|
171
171
|
|
|
172
|
-
//
|
|
173
|
-
|
|
172
|
+
// COSTRUZIONE XML CON FORMATTAZIONE PULITA A LIVELLI (Risolve l'errore "two root tags")
|
|
173
|
+
let searchXml = `<?xml version="1.0" encoding="utf-8"?>\n` +
|
|
174
|
+
`<CMSearchDescription>\n` +
|
|
175
|
+
` <searchID>LAST_EVENT</searchID>\n` +
|
|
176
|
+
` <trackIDList>\n` +
|
|
177
|
+
` <trackID>${t.id}</trackID>\n` +
|
|
178
|
+
` </trackIDList>\n` +
|
|
179
|
+
` <timeSpanList>\n` +
|
|
180
|
+
` <timeSpan>\n` +
|
|
181
|
+
` <startTime>${startTime}</startTime>\n` +
|
|
182
|
+
` <endTime>${endTime}</endTime>\n` +
|
|
183
|
+
` </timeSpan>\n` +
|
|
184
|
+
` </timeSpanList>\n`;
|
|
185
|
+
|
|
186
|
+
// Inseriamo il contentTypeList SOLO per la foto, per la ricerca video standard dell'NVR va rimosso!
|
|
187
|
+
if (t.isFoto) {
|
|
188
|
+
searchXml += ` <contentTypeList>\n` +
|
|
189
|
+
` <contentType>metadata</contentType>\n` +
|
|
190
|
+
` </contentTypeList>\n`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
searchXml += ` <maxResults>30</maxResults>\n` +
|
|
194
|
+
` <searchResultPostion>0</searchResultPostion>\n` +
|
|
195
|
+
` <metadataList>\n` +
|
|
196
|
+
` <metadataDescriptor>recordType.meta.hikvision.com/${eventoNVR}</metadataDescriptor>\n` +
|
|
197
|
+
` </metadataList>\n` +
|
|
198
|
+
`</CMSearchDescription>`;
|
|
174
199
|
|
|
175
200
|
node.warn(`[STEP 4.1] Invio POST /search per traccia ${t.id}. XML inviato:\n${searchXml}`);
|
|
176
201
|
|
|
@@ -182,7 +207,7 @@ module.exports = function(RED) {
|
|
|
182
207
|
headers: { "Content-Type": "application/xml" }
|
|
183
208
|
});
|
|
184
209
|
|
|
185
|
-
node.warn(`[STEP 4.2] Risposta ricevuta da /search per traccia ${t.id}:
|
|
210
|
+
node.warn(`[STEP 4.2] Risposta ricevuta da /search per traccia ${t.id}: Status ${resSearch.status}`);
|
|
186
211
|
|
|
187
212
|
let xml = resSearch.data.replace(/<(\/?)\w+:/g, "<$1");
|
|
188
213
|
const uriMatch = xml.match(/<playbackURI>([^<]+)</);
|
|
@@ -234,7 +259,6 @@ module.exports = function(RED) {
|
|
|
234
259
|
node.warn(`[STEP 4.3] Nessun playbackURI trovato nel documento di risposta XML per traccia ${t.id}. XML di risposta:\n${resSearch.data}`);
|
|
235
260
|
}
|
|
236
261
|
} catch (searchError) {
|
|
237
|
-
// CATTURA DETTAGLIATA DELL'ERRORE 400
|
|
238
262
|
let errorDetails = searchError.message;
|
|
239
263
|
if (searchError.response) {
|
|
240
264
|
errorDetails += ` | Status: ${searchError.response.status} | Dati Risposta: ${JSON.stringify(searchError.response.data)}`;
|
|
@@ -259,7 +283,7 @@ module.exports = function(RED) {
|
|
|
259
283
|
} catch (e) {
|
|
260
284
|
node.error(`[FATAL ERROR] Blocco principale downloadMedia fallito: ${e.message}`);
|
|
261
285
|
}
|
|
262
|
-
|
|
286
|
+
node.status({fill:"green", shape:"ring", text:"In ascolto"});
|
|
263
287
|
}
|
|
264
288
|
|
|
265
289
|
function startAlertStream() {
|