node-red-contrib-hik-media-buffer 1.1.10 → 1.1.11
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 -7
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -42,17 +42,26 @@ module.exports = function(RED) {
|
|
|
42
42
|
|
|
43
43
|
// --- PRENDE IL NOME DELLA TELECAMERA ---
|
|
44
44
|
async function getCameraName(cam) {
|
|
45
|
+
const camAuth = new AxiosDigestAuth({
|
|
46
|
+
username: node.user,
|
|
47
|
+
password: node.camPass
|
|
48
|
+
});
|
|
49
|
+
|
|
45
50
|
try {
|
|
46
|
-
|
|
51
|
+
// Chiediamo le info generali del dispositivo (valido per TUTTE le Hikvision)
|
|
52
|
+
const res = await camAuth.request({
|
|
47
53
|
method: 'GET',
|
|
48
|
-
url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/
|
|
49
|
-
|
|
50
|
-
pass: node.camPass
|
|
54
|
+
url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/deviceInfo`,
|
|
55
|
+
timeout: 5000
|
|
51
56
|
});
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
|
|
58
|
+
const data = res.data.toString();
|
|
59
|
+
// Nelle info dispositivo il nome è dentro <deviceName>
|
|
60
|
+
const match = data.match(/<deviceName>([^<]+)<\/deviceName>/i);
|
|
61
|
+
|
|
62
|
+
return match ? match[1] : `Cam_${cam.ip}`;
|
|
54
63
|
} catch (e) {
|
|
55
|
-
return `Camera_${cam.ip}`;
|
|
64
|
+
return `Camera_${cam.ip}`;
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
|