node-red-contrib-hik-media-buffer 1.1.127 → 1.1.129
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 +24 -10
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -32,8 +32,19 @@ module.exports = function(RED) {
|
|
|
32
32
|
|
|
33
33
|
node.status({fill:"grey", shape:"ring", text:"Inizializzazione..."});
|
|
34
34
|
|
|
35
|
+
// --- FORMATTAZIONE DATA LOCALE (Risolve il bug delle 2 ore di differenza dell'NVR) ---
|
|
35
36
|
function toHikSearchDate(d) {
|
|
36
|
-
|
|
37
|
+
const pad = (num) => String(num).padStart(2, '0');
|
|
38
|
+
|
|
39
|
+
const year = d.getFullYear();
|
|
40
|
+
const month = pad(d.getMonth() + 1);
|
|
41
|
+
const day = pad(d.getDate());
|
|
42
|
+
const hours = pad(d.getHours());
|
|
43
|
+
const minutes = pad(d.getMinutes());
|
|
44
|
+
const seconds = pad(d.getSeconds());
|
|
45
|
+
|
|
46
|
+
// Costruisce la stringa mantenendo l'ora locale del PC/Node-RED (es. 09:53:19Z)
|
|
47
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
// --- 1. PRENDE IL NOME REALE DELLA TELECAMERA DAL DIGITAL PROXY ---
|
|
@@ -125,8 +136,8 @@ module.exports = function(RED) {
|
|
|
125
136
|
if (nowTime - lastTriggerTime[channelID] < 5000) return;
|
|
126
137
|
lastTriggerTime[channelID] = nowTime;
|
|
127
138
|
|
|
128
|
-
node.status({fill:"yellow", shape:"dot", text:`Attesa scrittura NVR (
|
|
129
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
139
|
+
node.status({fill:"yellow", shape:"dot", text:`Attesa scrittura NVR (6s)...`});
|
|
140
|
+
await new Promise(resolve => setTimeout(resolve, 6000));
|
|
130
141
|
|
|
131
142
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
132
143
|
const referenceTime = new Date();
|
|
@@ -137,12 +148,15 @@ module.exports = function(RED) {
|
|
|
137
148
|
node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
|
|
138
149
|
|
|
139
150
|
const inizioFinestra = new Date(referenceTime.getTime() - (2 * 60 * 1000));
|
|
140
|
-
const fineFinestra = new Date(referenceTime.getTime() + (
|
|
151
|
+
const fineFinestra = new Date(referenceTime.getTime() + (2 * 60 * 1000));
|
|
141
152
|
|
|
142
|
-
const
|
|
143
|
-
const
|
|
153
|
+
const startVideoSearch = toHikSearchDate(inizioFinestra);
|
|
154
|
+
const endVideoSearch = toHikSearchDate(fineFinestra);
|
|
155
|
+
|
|
156
|
+
const startFotoSearch = inizioFinestra.toISOString().split('.')[0] + "Z";
|
|
157
|
+
const endFotoSearch = fineFinestra.toISOString().split('.')[0] + "Z";
|
|
144
158
|
|
|
145
|
-
node.warn(`[DEBUG HIK] Avvio ricerca video. Canale: ${channelID}. Cerco da: ${
|
|
159
|
+
node.warn(`[DEBUG HIK] Avvio ricerca video. Canale: ${channelID}. Cerco da: ${startVideoSearch} a: ${endVideoSearch}`);
|
|
146
160
|
|
|
147
161
|
let output = {
|
|
148
162
|
tipo_messaggio: "evento",
|
|
@@ -166,7 +180,7 @@ module.exports = function(RED) {
|
|
|
166
180
|
"searchID": "C5AFEE35-B1E0-4C01-83F8-47FD77892E4A",
|
|
167
181
|
"searchResultPosition": 0,
|
|
168
182
|
"maxResults": 1,
|
|
169
|
-
"timeSpanList": [{ "startTime":
|
|
183
|
+
"timeSpanList": [{ "startTime": startFotoSearch, "endTime": endFotoSearch }],
|
|
170
184
|
"type": "all",
|
|
171
185
|
"channels": [parseInt(channelID)],
|
|
172
186
|
"eventType": "behavior",
|
|
@@ -205,8 +219,8 @@ module.exports = function(RED) {
|
|
|
205
219
|
<trackList><trackID>${videoTrackID}</trackID></trackList>
|
|
206
220
|
<timeSpanList>
|
|
207
221
|
<timeSpan>
|
|
208
|
-
<startTime>${
|
|
209
|
-
<endTime>${
|
|
222
|
+
<startTime>${startVideoSearch}</startTime>
|
|
223
|
+
<endTime>${endVideoSearch}</endTime>
|
|
210
224
|
</timeSpan>
|
|
211
225
|
</timeSpanList>
|
|
212
226
|
<maxResults>1</maxResults>
|