node-red-contrib-hik-media-buffer 1.1.119 → 1.1.120
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 +16 -6
- package/package.json +1 -2
package/hik-media-buffer.js
CHANGED
|
@@ -62,7 +62,6 @@ module.exports = function(RED) {
|
|
|
62
62
|
if (isClosing || !nvrOnline) return;
|
|
63
63
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
64
64
|
try {
|
|
65
|
-
// Interroghiamo l'elenco proxy centralizzato dell'NVR
|
|
66
65
|
const res = await nvrAuth.request({
|
|
67
66
|
method: 'GET',
|
|
68
67
|
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels`,
|
|
@@ -71,17 +70,28 @@ module.exports = function(RED) {
|
|
|
71
70
|
});
|
|
72
71
|
|
|
73
72
|
const xml = res.data.toString();
|
|
74
|
-
//
|
|
73
|
+
// Isola ogni blocco <InputProxyChannel>
|
|
75
74
|
const channelBlocks = xml.match(/<InputProxyChannel>[\s\S]*?<\/InputProxyChannel>/g) || [];
|
|
76
75
|
|
|
77
76
|
for (let block of channelBlocks) {
|
|
78
77
|
const idMatch = block.match(/<id>(\d+)<\/id>/i);
|
|
79
|
-
// Questa regex cerca la parola "true" o "false" dentro il tag online, sia esso <online>, <onLine> o <ONLINE>
|
|
80
|
-
const onlineMatch = block.match(/<onLine[^>]*>(true|false)<\/onLine>/i) || block.match(/<online[^>]*>(true|false)<\/online>/i);
|
|
81
78
|
|
|
82
79
|
if (idMatch) {
|
|
83
80
|
const ch = idMatch[1];
|
|
84
|
-
|
|
81
|
+
let isOnline = false;
|
|
82
|
+
|
|
83
|
+
// Cattura il testo tra <online...> e </online> o <onLine...> e </onLine>
|
|
84
|
+
// gestendo la presenza di attributi come opt="true,false" (Specifiche Pag. 156/162)
|
|
85
|
+
const rawOnlineMatch = block.match(/<online[^>]*>([\s\S]*?)<\/online>/i) ||
|
|
86
|
+
block.match(/<onLine[^>]*>([\s\S]*?)<\/onLine>/i);
|
|
87
|
+
|
|
88
|
+
if (rawOnlineMatch && rawOnlineMatch[1]) {
|
|
89
|
+
const val = rawOnlineMatch[1].trim().toLowerCase();
|
|
90
|
+
// Se il testo contiene "true", la telecamera è online
|
|
91
|
+
if (val.includes("true")) {
|
|
92
|
+
isOnline = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
85
95
|
|
|
86
96
|
if (isOnline && statoCamera[ch] === false) {
|
|
87
97
|
const nomeOnline = await getCameraNameFromNVR(ch);
|
|
@@ -91,7 +101,7 @@ module.exports = function(RED) {
|
|
|
91
101
|
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "offline", nome_cliente: node.name, nome_telecamera: `Camera ${ch}`, ip_telecamera: node.host, channel: ch, msg: "Camera non raggiungibile" } });
|
|
92
102
|
statoCamera[ch] = false;
|
|
93
103
|
} else if (statoCamera[ch] === undefined) {
|
|
94
|
-
//
|
|
104
|
+
// Boot iniziale: salva lo stato rilevato senza inviare messaggi spuri
|
|
95
105
|
statoCamera[ch] = isOnline;
|
|
96
106
|
}
|
|
97
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-hik-media-buffer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.120",
|
|
4
4
|
"description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mhoc/axios-digest-auth": "^0.8.0",
|
|
24
24
|
"axios": "^1.6.0",
|
|
25
|
-
"node-red-contrib-hik-media-buffer": "^1.1.109",
|
|
26
25
|
"xml2js": "^0.6.2"
|
|
27
26
|
}
|
|
28
27
|
}
|