node-red-contrib-hik-media-buffer 1.1.113 → 1.1.114
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 +6 -10
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -68,16 +68,14 @@ module.exports = function(RED) {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
const xml = res.data.toString();
|
|
71
|
-
// Regex per estrarre ogni blocco VideoInputChannel
|
|
72
71
|
const channelBlocks = xml.match(/<VideoInputChannel>[\s\S]*?<\/VideoInputChannel>/g) || [];
|
|
73
72
|
|
|
74
73
|
for (let block of channelBlocks) {
|
|
75
74
|
const idMatch = block.match(/<id>(\d+)<\/id>/i);
|
|
76
|
-
const statusMatch = block.match(/<resVerType>([^<]+)<\/resVerType>/i);
|
|
75
|
+
const statusMatch = block.match(/<resVerType>([^<]+)<\/resVerType>/i);
|
|
77
76
|
|
|
78
77
|
if (idMatch) {
|
|
79
78
|
const ch = idMatch[1];
|
|
80
|
-
// Se non trova il tag esplicito o dice "online", assumiamo sia attiva
|
|
81
79
|
const isOnline = statusMatch ? statusMatch[1].toLowerCase() === "online" : true;
|
|
82
80
|
|
|
83
81
|
if (isOnline && statoCamera[ch] === false) {
|
|
@@ -92,9 +90,7 @@ module.exports = function(RED) {
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
} catch (e) {
|
|
96
|
-
// Se l'NVR fallisce la chiamata generale, lo gestisce l'alert stream o lasciamo lo stato immutato
|
|
97
|
-
}
|
|
93
|
+
} catch (e) {}
|
|
98
94
|
updateNodeStatus();
|
|
99
95
|
}
|
|
100
96
|
|
|
@@ -128,7 +124,7 @@ module.exports = function(RED) {
|
|
|
128
124
|
const nomeCamera = await getCameraNameFromNVR(channelID);
|
|
129
125
|
node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
|
|
130
126
|
|
|
131
|
-
// Finestra temporale
|
|
127
|
+
// Finestra temporale per la ricerca foto JSON
|
|
132
128
|
const startSearchStr = referenceTime.toISOString().split('T')[0] + "T00:00:00 01:00";
|
|
133
129
|
const endSearchStr = referenceTime.toISOString().split('T')[0] + "T23:59:59 01:00";
|
|
134
130
|
|
|
@@ -173,8 +169,9 @@ module.exports = function(RED) {
|
|
|
173
169
|
httpsAgent: node.protocol === "https" ? httpsAgent : undefined
|
|
174
170
|
});
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
// CORRETTO: Adesso cerca dentro Targets e prende il pictureUrl grezzo come su Postman
|
|
173
|
+
if (resFotoSearch.data?.EventSearchResult?.Targets?.[0]?.pictureUrl) {
|
|
174
|
+
const urlFotoGrezzo = resFotoSearch.data.EventSearchResult.Targets[0].pictureUrl;
|
|
178
175
|
|
|
179
176
|
const resDownFoto = await nvrAuth.request({
|
|
180
177
|
method: 'GET',
|
|
@@ -190,7 +187,6 @@ module.exports = function(RED) {
|
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
// 2. SCARICAMENTO VIDEO (POST XML a search -> GET XML a download)
|
|
193
|
-
// Usiamo una finestra temporale estesa in formato Z come richiesto dall'NVR
|
|
194
190
|
const startVideoSearch = referenceTime.toISOString().split('T')[0] + "T00:00:00Z";
|
|
195
191
|
const endVideoSearch = referenceTime.toISOString().split('T')[0] + "T23:59:59Z";
|
|
196
192
|
|