Terminal, is Kodi being used
#1
I've setup a script i wrote to run every hour. Its important the script runs but i find it slows down my HTPC when i am using it, and there is no big rush as long as it runs eventually.

Is there a way via script to tell if kodi is playing a video or better yet active in anyway (like browsing through the library...)

Ive looked into
Code:
kodi-send -a "Notification(, )";
but cant seem to find much in terms of getting status back.

I found an old post about idle detection but my box reports true on these conditions even when my HTPC has been untouched for hours.

any ideas? thanks,
Reply
#2
Take a look at the JSON RPC stuff:

http://kodi.wiki/view/JSON-RPC_API

It looks like there's a JSON call to get all the active players:

http://kodi.wiki/view/JSON-RPC_API/v6#Pl...ivePlayers

That second link has every JSON call you can make and the replies.
Reply
#3
perfect, thanks
Reply
#4
This does the job:
curl -s -u kodi:kodi -X POST -H 'Content-type: application/json' -d '{"jsonrpc": "2.0", "method": "Player.GetItem", "params": {"playerid":1 }, "id": 1}' http://localhost:8080/jsonrpc

how would i achieve this via python?
Reply
#5
I am using this:

Code:
def getJson(method, param1, param2, retname):
    command = '''{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "%s",
    "params": {
        "%s": "%s"
        }
    }'''

    result = xbmc.executeJSONRPC(command % (method, param1, param2))
    py = json.loads(result)
    if 'result' in py and retname in py['result']:
        a = py['result'][retname]
        return a
    else:
        raise ValueError

It has 2 params but can be easily modified...

i.e. calling it by

SubFirst = getJson("Settings.GetSettingValue", "setting", "subtitles.downloadfirst", "value")

Ah, you ofcourse need

import json

at the beginning

D.
Reply
#6
exactly what i needed, thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Terminal, is Kodi being used0