Code: Select all
:local IP "10.111.0.22"
:local name "Senzi"
:local file "sdcard/json-$name.txt"
/tool fetch url="http://$IP/jsonrpc?request={\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}" mode=http dst-path=$file
:delay 1
:local json [/file get $file contents]
:if ([:find $json "video"] + 0 = 0) do={
/log info "TV $name play"
/tool fetch url="http://$IP/jsonrpc?request={\"jsonrpc\":\"2.0\",\"method\":\"Player.Open\",\"params\":{\"item\":{\"playlistid\":0},\"options\":{\"repeat\":\"all\"}},\"id\":1}" mode=http keep-result=no
}
/file remove $file
- each time a file is created - it is using flash or sdcard
- log is full of "info - fetch: file ... downloaded"
So - is there a way to improve the script? It would be very nice if the file will not be necessary - is it possible to fetch to variable?