2019-04-06, 00:48
(2019-04-03, 12:53)redespace Wrote: Hi Everyone,
Hopefully some of you clever guys can help me out. I have Kodi running on a Rpi (Libreelec) and what I had a script running that checked if there was any video playing on Kodi.
My script is:
Code:playing=1
myvar=""
myvar=$(curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "Player.GetItem", "params":{"properties": ["tvshowid"], "playerid": 1}, "id": "VideoGetItem"}' http://[username]:[pass]@127.0.0.1:58080/jsonrpc)
case "$myvar" in
*unknown*) playing=0 ;;
* ) ;;
esac
while $playing == 1 (wiki)
do
myvar=""
myvar=$(curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "Player.GetItem", "params":{"properties": ["tvshowid"], "playerid": 1}, "id": "VideoGetItem"}' http://[username]:[pass]@127.0.0.1:58080/jsonrpc);
case "$myvar" in
*unknown*) playing=0 ;;
* ) ;;
esac
sleep 900
done
The problem I am having is that since LEIA came out, this is not working anymore. The variable is returning:
Code:MyPI:~/.config # $myvar
-sh: <html><head><title>File: not found
Any ideas what could be the problem?
Have you tried:
1. Put the http address in front of -d (i.e...
Code:
myvar=$(curl -s -H 'Content-Type: application/json' http://[username]:[pass]@127.0.0.1:58080/jsonrpc -d '{"jsonrpc": "2.0", "method": "Player.GetItem", "params":{"properties": ["tvshowid"], "playerid": 1}, "id": "VideoGetItem"}' )
and/or
2. -X in curl, such as:
Code:
myvar=$(curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "Player.GetItem", "params":{"properties": ["tvshowid"], "playerid": 1}, "id": "VideoGetItem"}' http://[username]:[pass]@127.0.0.1:58080/jsonrpc)
I'm using Ubuntu server, which presumes GET unless you force it to POST method via -X POST