node-red-contrib-hik-media-buffer 1.1.97 → 1.1.99
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 +19 -7
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -118,9 +118,17 @@ module.exports = function(RED) {
|
|
|
118
118
|
const referenceTime = new Date();
|
|
119
119
|
const timestamp = Math.floor(referenceTime.getTime() / 1000);
|
|
120
120
|
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
121
|
+
// Forziamo l'azzeramento totale dei secondi (:00 e :59) come vuole il database Hikvision
|
|
122
|
+
const dStart = new Date(referenceTime.getTime() - (5 * 60 * 1000)); // 5 minuti fa
|
|
123
|
+
dStart.setSeconds(0, 0); // Forza :00 secondi e 0 millisecondi
|
|
124
|
+
|
|
125
|
+
const dEnd = new Date(referenceTime.getTime() + (2 * 60 * 1000)); // 2 minuti nel futuro
|
|
126
|
+
dEnd.setSeconds(59, 999); // Forza :59 secondi
|
|
127
|
+
|
|
128
|
+
const startTime = toJsonDate(dStart);
|
|
129
|
+
const endTime = toJsonDate(dEnd);
|
|
130
|
+
|
|
131
|
+
node.warn(`[DEBUG TEMPO SANIFICATO] Cerco da: ${startTime} a: ${endTime}`);
|
|
124
132
|
|
|
125
133
|
node.status({fill:"yellow", shape:"dot", text:`Ricerca Evento Cam ${channelID}...`});
|
|
126
134
|
|
|
@@ -136,21 +144,25 @@ module.exports = function(RED) {
|
|
|
136
144
|
let fileDaCancellare = [];
|
|
137
145
|
|
|
138
146
|
try {
|
|
139
|
-
//
|
|
147
|
+
// Ripristiniamo il SearchID dinamico
|
|
140
148
|
const dynamicSearchId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
141
149
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
142
150
|
return v.toString(16).toUpperCase();
|
|
143
151
|
});
|
|
144
152
|
|
|
145
|
-
//
|
|
153
|
+
// Ricostruiamo il JSON IDENTICO a quello intercettato su Chrome che funzionava
|
|
146
154
|
const searchPayload = {
|
|
147
155
|
"EventSearchDescription": {
|
|
148
156
|
"searchID": dynamicSearchId,
|
|
149
157
|
"searchResultPosition": 0,
|
|
150
|
-
"maxResults":
|
|
158
|
+
"maxResults": 30,
|
|
151
159
|
"timeSpanList": [{ "startTime": startTime, "endTime": endTime }],
|
|
152
160
|
"type": "all",
|
|
153
|
-
"channels": [ parseInt(channelID
|
|
161
|
+
"channels": [ parseInt(channelID) ], // Ritorniamo al canale puro (es. 2)
|
|
162
|
+
"eventType": "behavior",
|
|
163
|
+
"behavior": {
|
|
164
|
+
"behaviorEventType": evento.toLowerCase() // Spara "linedetection" o "fielddetection"
|
|
165
|
+
}
|
|
154
166
|
}
|
|
155
167
|
};
|
|
156
168
|
const tempJsonPath = path.join(baseStorage, `search_${channelID}_${timestamp}.json`);
|