node-red-contrib-hik-media-buffer 1.1.11 → 1.1.13

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.
@@ -48,20 +48,39 @@ module.exports = function(RED) {
48
48
  });
49
49
 
50
50
  try {
51
- // Chiediamo le info generali del dispositivo (valido per TUTTE le Hikvision)
51
+ // Interroghiamo il CANALE specifico (es. /channels/2)
52
52
  const res = await camAuth.request({
53
53
  method: 'GET',
54
- url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/deviceInfo`,
55
- timeout: 5000
54
+ url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/Video/inputs/channels/${cam.channel}`,
55
+ timeout: 5000,
56
+ httpsAgent: node.protocol === "https" ? httpsAgent : undefined
56
57
  });
57
58
 
58
59
  const data = res.data.toString();
59
- // Nelle info dispositivo il nome è dentro <deviceName>
60
- const match = data.match(/<deviceName>([^<]+)<\/deviceName>/i);
61
60
 
62
- return match ? match[1] : `Cam_${cam.ip}`;
61
+ // In questo XML il tag è solitamente <name>
62
+ const match = data.match(/<name>([^<]+)<\/name>/i);
63
+
64
+ if (match && match[1]) {
65
+ return match[1].trim(); // Restituirà "Ufficio"
66
+ } else {
67
+ return `Canale_${cam.channel}`;
68
+ }
69
+
63
70
  } catch (e) {
64
- return `Camera_${cam.ip}`;
71
+ // Se l'URL sopra fallisce (alcuni modelli vecchi), proviamo questo URL alternativo
72
+ try {
73
+ const resAlt = await camAuth.request({
74
+ method: 'GET',
75
+ url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels/${cam.channel}`,
76
+ timeout: 3000
77
+ });
78
+ const dataAlt = resAlt.data.toString();
79
+ const matchAlt = dataAlt.match(/<name>([^<]+)<\/name>/i);
80
+ return matchAlt ? matchAlt[1].trim() : `Cam_${cam.channel}`;
81
+ } catch (err) {
82
+ return `Camera_${cam.ip}`;
83
+ }
65
84
  }
66
85
  }
67
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",