Channel favorites copying/duplicating/restoring.

Adding channel favorites is something that can take up a verry long time, as i didn't want to do this again for every device in our house i've build a simple script. Im sharing it because, who knows it might save someone some time. I'm not providing any support/help on the script but i'm sure that those who have saved a lot of time by using this script will spend some time to help out ;-)

  1. Copy the script below in a .js file.
  2. Use NPM to install http.min
  3. make or use a backup.json file generated with API call http://brainIp:3000/projects/home
  4. Change the configuration settings, in my example the source is taken from room named Livingroom and device named TV. set the roomkey and device key of the device where you want to have the favorites set to.

 

// get file by saving content of http://brainIp:3000/projects/home to backup.json


// Configuration source
const BACKUPJSON = require("./backup.json");
const SOURCEROOM = "Livingroom";
const SOURCEDEVICE = "TV";


// Configuration target
const NEEOBRAIN = "10.10.10.10";
const ROOMKEY = "6451290706151804928";
const DEVICEKEY = "6451131224098291552";
const TIMEBETWEENAPICALLS = 1000;


// Favorite channel cloning code.

const CHANNELS = BACKUPJSON.rooms[SOURCEROOM].devices[SOURCEDEVICE].favorites;
var http = require("http.min");
let i = 0;

function addchannel() {
  console.log(CHANNELS[i].channel.name);
  http.post(`http://${NEEOBRAIN}:3000/v1/projects/home/rooms/${ROOMKEY}/devices/${DEVICEKEY}/favorites/${i}?limit=-1`, CHANNELS[i]).then(function(result) {
    console.log("Code: " + result.response.statusCode);
  });
  if (i < CHANNELS.length) {
    setTimeout(function() {
      i++;
      addchannel();
    }, TIMEBETWEENAPICALLS);
  }
}

addchannel();
Reply
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
reply to topic
Like3 Follow