node-red-contrib-hik-media-buffer 1.1.83 → 1.1.84
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 +5 -11
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -127,29 +127,23 @@ module.exports = function(RED) {
|
|
|
127
127
|
let fileDaCancellare = [];
|
|
128
128
|
|
|
129
129
|
try {
|
|
130
|
+
try { await nvrAuthAxios.request({ method: 'POST', url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/search`, data: "" }); } catch(e) {}
|
|
130
131
|
const trackV = (channelID * 100 + 1).toString();
|
|
131
132
|
const trackI = (channelID * 100 + 3).toString();
|
|
132
133
|
const tracks = [{ id: trackV }, { id: trackI }];
|
|
133
|
-
|
|
134
|
+
let searchXml = ``;
|
|
134
135
|
for (let t of tracks) {
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
if (t.id === trackV) {
|
|
137
138
|
searchXml = `<?xml version="1.0" encoding="utf-8"?><CMSearchDescription><searchID>LAST_EVENT</searchID><trackList><trackID>${t.id}</trackID></trackList><timeSpanList><timeSpan><startTime>${startTime}</startTime><endTime>${endTime}</endTime></timeSpan></timeSpanList><maxResults>100</maxResults><searchResultPostion>0</searchResultPostion><metadataList><metadataDescriptor>//recordType.meta.std-cgi.com</metadataDescriptor></metadataList></CMSearchDescription>`;
|
|
138
139
|
} else {
|
|
139
140
|
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><searchResultPostion>0</searchResultPostion><metadataList><metadataDescriptor>recordType.meta.hikvision.com/${evento}</metadataDescriptor></metadataList></CMSearchDescription>`;
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
-
// Forza l'XML in un buffer per evitare che Axios sballi la lunghezza della stringa HTTP
|
|
143
|
-
const xmlBuffer = Buffer.from(searchXml, 'utf-8');
|
|
144
|
-
|
|
145
142
|
const resSearch = await nvrAuthAxios.request({
|
|
146
143
|
method: 'POST',
|
|
147
144
|
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/search`,
|
|
148
|
-
data:
|
|
149
|
-
headers: {
|
|
150
|
-
"Content-Type": "application/xml; charset=UTF-8",
|
|
151
|
-
"Content-Length": xmlBuffer.length
|
|
152
|
-
}
|
|
145
|
+
data: searchXml,
|
|
146
|
+
headers: { "Content-Type": "application/xml; charset=UTF-8" }
|
|
153
147
|
});
|
|
154
148
|
|
|
155
149
|
let xml = resSearch.data.replace(/<(\/?)\w+:/g, "<$1");
|