I wrote that for @psperry case, when he found that often some recorded shows are not processed.
const {exec} = require('child_process');
const http = require('http');
let url = "http://localhost:8089/dvr/files";
http.get(url, (res)=>{
var needprocessing =[];
var chunks =[];
res.on("data", (data) => {
chunks.push(data);
}).on("end", () => {
let data = Buffer.concat(chunks);
let channels = JSON.parse(data);
let check = channels.some((obj) => obj.Duration == 0);
if (check) {
channels.map((obj) => {
if (obj.Duration == 0 && obj.Completed === true) {
needprocessing.push(obj.ID);
}
});
} else {
console.log("No items find to process");
}
if (needprocessing.length > 0) {
for (const id of needprocessing) {
var args =
"'-X PUT' http://localhost:8089/dvr/files/" +
parseInt(id) +
"/reprocess";
exec("/usr/bin/curl " + args, function (error, stdout, stderr) {
console.log("stdout:" + stdout);
console.log("stderr:" + stderr);
if (error != null) {
console.log("exec error " + error);
}
});
}
}
});
}).on('error', (err)=>{
console.error("Tricky"+err.message);
});
Happy New Year to everyone, I hope 2022 be better for us, I wish you all good health, new challenges, fascinated stories to read and watch and lot of love