Close

KODI Stuff

A project log for Multifunction Media Center Display

Digital clock, NBA scoreboard and media play status using LilyGO T-Display-S3

linuslinus 6 days ago0 Comments

For json_rpc to work make sure you have Allow remote control via HTTP activated on the Control tab of Setting/Services.

How to query KODI to display play time and play duration:

curl -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["Player.Time","Player.Duration"] },"id": 1}'

or if you have a password set:

curl -X POST -H "content-type:application/json" http://kodi:kodi@192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["Player.Time","Player.Duration"] },"id": 1}'

or a simple scrip to output well formatted info that looks like 00:40:22/01:43:20

#!/bin/bash

read line < <(curl -s -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["VideoPlayer.Duration"] },"id": 1}' | grep -o -P '(?<=Duration":").*?(?="}})') read line2 < <(curl -s -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["VideoPlayer.Time"] },"id": 1}' | grep -o -P '(?<=Time":").*?(?="}})') echo "$line2/$line"

Discussions