Script for reprocess missed shows

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 :smiling_face_with_three_hearts: :partying_face:

2 Likes

It works perfectly in just a few seconds and only reprocesses the episodes that show zero length but are complete -- which was only a handful in my case because I try to keep up with them manually. It also ended up exposing several recordings that had become corrupted over the years and were no longer playable. So it helped me clean up my library a bit.

Thanks @beyo77 !

1 Like