node-red-contrib-hik-media-buffer 1.1.48 → 1.1.49

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.
@@ -78,7 +78,8 @@ module.exports = function(RED) {
78
78
  while ((matchBlocco = bloccoRegex.exec(xmlData)) !== null) {
79
79
  const bloccoContenuto = matchBlocco[1];
80
80
 
81
- const idMatch = bloccoContenited.match(/<id>(\d+)<\/id>/i);
81
+ // FISSO: Corretto il nome della variabile bloccoContenuto (prima c'era un typo che rompeva il nodo)
82
+ const idMatch = bloccoContenuto.match(/<id>(\d+)<\/id>/i);
82
83
  const statusMatch = bloccoContenuto.match(/<status>([^<]+)</i);
83
84
 
84
85
  if (idMatch && statusMatch) {
@@ -130,7 +131,6 @@ module.exports = function(RED) {
130
131
  const referenceTime = new Date();
131
132
  const timestamp = Math.floor(referenceTime.getTime() / 1000);
132
133
 
133
- // Finestra temporale basata sulle date ISO
134
134
  const startTime = toHikDate(new Date(referenceTime.getTime() - (20 * 1000)));
135
135
  const endTime = toHikDate(new Date(referenceTime.getTime() + (20 * 1000)));
136
136
 
@@ -140,7 +140,6 @@ module.exports = function(RED) {
140
140
  await new Promise(resolve => setTimeout(resolve, 6000));
141
141
  const baseUrl = `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt`;
142
142
 
143
- // Ricostruiamo l'evento con il case-sensitive corretto per l'NVR (FieldDetection / LineDetection)
144
143
  let eventoNVR = "FieldDetection";
145
144
  for (let e of EventList) {
146
145
  if (evento.toLowerCase() === e.toLowerCase()) {
@@ -174,7 +173,7 @@ module.exports = function(RED) {
174
173
 
175
174
  try {
176
175
  for (let t of tracks) {
177
- // COPIATO DALL'ISPEZIONA: Inserito <contentTypeList> e corretto metadataDescriptor proprietario hikvision
176
+ // FISSO: Logica XML clonata al 100% dal tuo ispeziona NVR reale
178
177
  const searchXml = `<?xml version="1.0" encoding="utf-8"?><CMSearchDescription><searchID>LAST_EVENT</searchID><trackIDList><trackID>${t.id}</trackID></trackIDList><timeSpanList><timeSpan><startTime>${startTime}</startTime><endTime>${endTime}</endTime></timeSpan></timeSpanList><contentTypeList><contentType>metadata</contentType></contentTypeList><maxResults>30</maxResults><metadataList><metadataDescriptor>recordType.meta.hikvision.com/${eventoNVR}</metadataDescriptor></metadataList></CMSearchDescription>`;
179
178
 
180
179
  const resSearch = await camAuth.request({
@@ -195,13 +194,11 @@ module.exports = function(RED) {
195
194
 
196
195
  let buffer = Buffer.from(resDown.data);
197
196
  if (t.isFoto) {
198
- // SALVA FOTO TERMICA NATIVA IN LOCALE
199
197
  const fullImgPath = path.join(baseStorage, `img_${timestamp}.jpg`);
200
198
  fs.writeFileSync(fullImgPath, buffer);
201
199
  output.foto_base64 = fs.readFileSync(fullImgPath, { encoding: 'base64' });
202
200
  fileDaCancellare.push(fullImgPath);
203
201
  } else {
204
- // SALVA VIDEO IN LOCALE
205
202
  if (buffer.slice(0, 4).toString() === 'IMKH') buffer = buffer.slice(40);
206
203
  const rawPath = path.join(baseStorage, `raw_${timestamp}.mp4`);
207
204
  const fixedPath = path.join(baseStorage, `hik_v_${channelID}_${timestamp}.mp4`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",