•   
  • 1
  • 8
  • 9
  • 10
  • 11
  • 12(current)
Working JSON RPC API Examples
@nissse Any luck finding a solution to the PVR Player.Open issue?  I'm able to accomplish the task via curl but unsuccessful via Javascript.
Code:
curl -s --data-binary '{"jsonrpc": "2.0", "method": "Player.Open","params":{"item":{"channelid":5}},"id": 1}' -H 'content-type: application/json;' http://$IP:8080/jsonrpc
Reply
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?
Reply
(2019-04-03, 12:53)redespace Wrote:  I had a script running that checked if there was any video playing on Kodi.
Any reason not to use python?
Quote:import xbmc
if xbmc.Player().isPlayingVideo():
    do summat
Reply
(2019-04-03, 13:12)trogggy Wrote:
(2019-04-03, 12:53)redespace Wrote:  I had a script running that checked if there was any video playing on Kodi.
Any reason not to use python?
Quote:import xbmc
if xbmc.Player().isPlayingVideo():
    do summat
@trogggy Didn't know that was an option Smile I tried it, but unfortunately failed:
Quote:ImportError: No module named xbmc
It seems from Kodi's forum post (326044 (thread)) that you cannot use XBMC's modules from outside Kodi. Do you have a way how to import it?
Reply
No, you're correct - you have to run it from kodi.  You could always do that using kodi-send, but I don't know whether that's your best option.  It was just a thought / alternative.
Reply
(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
Headless Linux Kodi box [Ubuntu 16.04.5 LTS Server] | Dedicated Media Server [Ubuntu 16.04.5 LTS Server]
Reply
Hi,
How to search in plugin.video.youtube?
Sorry for the Google translation.
Reply
(2019-08-13, 06:36)lysyi Wrote: Hi,
How to search in plugin.video.youtube?
Sorry for the Google translation.

3 questions:

1. What are you trying to accomplish?
2. Have you read the Kodi API Wiki?
3. What version number (major.minor) of Kodi are you using?
Headless Linux Kodi box [Ubuntu 16.04.5 LTS Server] | Dedicated Media Server [Ubuntu 16.04.5 LTS Server]
Reply
(2019-08-13, 21:31)HTGeek Wrote:
(2019-08-13, 06:36)lysyi Wrote: Hi,
How to search in plugin.video.youtube?
Sorry for the Google translation.

3 questions:

1. What are you trying to accomplish?
2. Have you read the Kodi API Wiki?
3. What version number (major.minor) of Kodi are you using? 

1. I want a window with the search result in the YouTube plug-in to appear on request.
2. I read ...
3.18.3
...

So it returns the search results in the response:
{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory": "plugin://plugin.video.youtube/kodion/search/query/?q=1080p" },"id":1}
So the search happens, the request is stored in the YouTube plugin:
{"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"plugin://plugin.video.youtube/kodion/search/query/?q=1080p"}}}
... but I would like just a window with search results.
Sorry for Google translation.
Reply
(2019-08-13, 22:00)lysyi Wrote:
(2019-08-13, 21:31)HTGeek Wrote:
(2019-08-13, 06:36)lysyi Wrote: Hi,
How to search in plugin.video.youtube?
Sorry for the Google translation.

3 questions:

1. What are you trying to accomplish?
2. Have you read the Kodi API Wiki?
3. What version number (major.minor) of Kodi are you using?   

1. I want a window with the search result in the YouTube plug-in to appear on request.
2. I read ...
3.18.3
... 

I would think that's a question for YouTube plug-in and not Kodi's API. The Kodi API is regarding the Kodi app itself... the core product. Another possibility is Google's YouTube API... but I suspect that even if you find a way to send a request via the YT API, you would have to find a way to pipe the response to a window in Kodi and then put it in focus (the last part is not hard to do if you can determine the Window ID).

Suggest asking here: 267160 (thread)
Headless Linux Kodi box [Ubuntu 16.04.5 LTS Server] | Dedicated Media Server [Ubuntu 16.04.5 LTS Server]
Reply
  •   
  • 1
  • 8
  • 9
  • 10
  • 11
  • 12(current)
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Working JSON RPC API Examples00