2019-03-07, 02:43
Greetings! I'm attempting to build a rudimentary web interface to send Kodi a few commands. I'd like to display what is currently airing on a few specific PVR channels. Thanks to a few examples on these forums, I'm able to connect to Kodi via websocket and retrieve the current on-air data. However, when the next program goes to air the EPG data does not update. Am I missing something or does a change to broadcastnow not trigger a websocket message? Is there another way to acquiring live updated JSON data? You help is greatly appreciated!
html:<html>
<body>
<script language="javascript" type="text/javascript">
var ws = new WebSocket('ws://localhost:9090/jsonrpc');
ws.onopen = function (event) {
send_message("PVR.GetChannelDetails", {
"properties": ["broadcastnow"],
"channelid": 32,
});
}
ws.onmessage = function (event) {
var j = JSON.parse(event.data);
var r = j.result.channeldetails.broadcastnow;
document.getElementById("name").innerHTML = r.title;
}
function send_message(method, params) {
var msg = {
"jsonrpc": "2.0",
"method": method,
"id": method
};
if (params) {
msg.params = params;
}
ws.send(JSON.stringify(msg));
}
</script>
<div id="name"></div>
</body>
</html>