Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- jasonvp - 2011-07-19

Montellese Wrote:"Library.Id" is a custom type that is defined in the json schema returned by JSONRPC.Introspect as well. What you can do is execute
Code:
{ "jsonrpc": "2.0", "method": "JSONRPC.Introspect", "params": { "filter": { "id": "Library.Id", "type": "type" } }, "id": 1 }
and you will only get the definition of "Library.Id". Basically "Library.Id" is a positive integer.

AudioLibrary.GetAlbums does not require any parameters but it can take the ID of an artist (retrieved through AudioLibrary.GetArtists) to only list the albums of a specific artist. AudioLibrary.GetAlbumDetails requires the ID of a specific album as a parameter.

Thanks a lot. It was my mistake that I was not getting any responses because I had not scanned my music through the Context Menu. First time user of XBMC. I guess it helps if your read the manual...doh!

Thanks again.

Cheers
Jason


Now playing item - mjeanrichard - 2011-07-22

Hi!

I am developing an Interface based on JSON-RPC. For the "Now playing" screen I use the playlist.getItems method to get the playlist and its current field to find out which is currently playing.

BUT:
If I remove the item, that is currently playing from the playlist (Playlist.Remove) the song keeps playing in XBMC (which ist ok). But now, the "current" field of the playlist.getItems method is not pointing so the current song since that song is not in the playlist anymore.
Is there any way to get the now playing song if the song is not in the playlist?

Thanks for your help!


- topfs2 - 2011-07-22

mjeanrichard Wrote:Hi!

I am developing an Interface based on JSON-RPC. For the "Now playing" screen I use the playlist.getItems method to get the playlist and its current field to find out which is currently playing.

BUT:
If I remove the item, that is currently playing from the playlist (Playlist.Remove) the song keeps playing in XBMC (which ist ok). But now, the "current" field of the playlist.getItems method is not pointing so the current song since that song is not in the playlist anymore.
Is there any way to get the now playing song if the song is not in the playlist?

Thanks for your help!

Are you using Playlist or the [Audio|Video]Playlist? you need to use the latter one for now playing (we want to switch this at a later stage when core works like it).


- mjeanrichard - 2011-07-22

I am using AudioPlaylist.GetItems.

also, if I have a Playlist that looks like this:

Song1
Song2
Song3
Song4

Lets assume that Song3 is currently playing. If I query AudioPlaylist.GetItems the current field is 2, which is correct.
If I remove Song1 from the playlist and requery getitems the current field is still 2, wich is wrong now, since Song3 is now on position 1.

It seems like the current field is only updated when the next song is played and not when the playlist is modified...??


- topfs2 - 2011-07-22

mjeanrichard Wrote:I am using AudioPlaylist.GetItems.

also, if I have a Playlist that looks like this:

Song1
Song2
Song3
Song4

Lets assume that Song3 is currently playing. If I query AudioPlaylist.GetItems the current field is 2, which is correct.
If I remove Song1 from the playlist and requery getitems the current field is still 2, wich is wrong now, since Song3 is now on position 1.

It seems like the current field is only updated when the next song is played and not when the playlist is modified...??

That is a bug for sure. Please submit a bugreport and CC me and montellese. Thanks.


- mjeanrichard - 2011-07-22

Ok, created Ticket http://trac.xbmc.org/ticket/11763.
Thanks for your help.


Files.Download - jasonvp - 2011-07-30

Hi Guys,

Does Files.Download work?

I tried this,
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.Download","params":"special://masterprofile/Thumbnails/Music/4/4484673b.tbn"}

All I get is,
Code:
{"error":{"code":-32600,"message":"Invalid request."},"id":1,"jsonrpc":"2.0"}

Are my params incorrect?

What does Files.Download return, the image or path?

I had a look in the introspect but Files.Download is not there. I'm using Nightly Build-20110715-5bbc9c2-master (windows XP).

I also tried to install the latest Nightly Build XBMCSetup-20110729-29bfb97-master.exe 29-Jul-2011 10:18 which installed but would not run.


Cheers
Jason


- topfs2 - 2011-07-30

jasonvp Wrote:Hi Guys,

Does Files.Download work?

I tried this,
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.Download","params":"special://masterprofile/Thumbnails/Music/4/4484673b.tbn"}

All I get is,
Code:
{"error":{"code":-32600,"message":"Invalid request."},"id":1,"jsonrpc":"2.0"}

Are my params incorrect?

That request is not valid on json-rpc 2.0 and has been changed in version 3, this is the schema for that method:
Code:
"Files.Download": {
    "type": "method",
    "transport": [ "Response", "FileDownload" ],
    "permission": "ReadData",
    "params": [
      { "name": "path", "type": "string", "required": true }
    ],
    "returns": {
      "type": "object",
      "properties": {
        "path": { "type": "string", "required": true }
      }
    }
  }

So you need to do
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.Download","params":{"path": "special://masterprofile/Thumbnails/Music/4/4484673b.tbn"}}

jasonvp Wrote:What does Files.Download return, the image or path?

Its hard to define what Files.Download "does" as it will depend on each transport. Essentially it initiates or prepares the server so that it can do a download, it will return something which will show you how to do the download. So parsing the data it returns depends on the transport.

To explain it way less complicated as the only transport implementing it is http, it will point to a path you can use to download the file.

Cheers,
Tobias


- jasonvp - 2011-07-30

Hi Tobias,

Thanks for your help.

I tried,
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.Download","params":{"path":"special://masterprofile/Thumbnails/Music/4/4484673b.tbn"}}

All I get is,
Code:
{"error":{"code":-32602,"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

I'm using Hercules to test with and a Nevo S70 remote both of which I get the same response.

Any idea's?


Cheers
Jason


- jasonvp - 2011-07-31

Hi,

So I tried,
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.Download","params":{"path":"special://masterprofile/Thumbnails/Music/4/4484673b.tbn"}}
using Simple REST Client and got no response.

Is this correct?
Image

I also tried,
Code:
{"jsonrpc":"2.0","id":1,"method":"JSONRPC.Ping"}
with no response.

Am I doing something wrong?


Cheers
Jason


- topfs2 - 2011-07-31

If you get no response it sounds like the webserver isn't active or that you have a wrong location to post to.

Would appreciate full debug logs.


- thedroid - 2011-07-31

jasonvp Wrote:Am I doing something wrong?


You need to add "/jsonrpc" to the end of your URL.


- jasonvp - 2011-08-01

thedroid Wrote:You need to add "/jsonrpc" to the end of your URL.

That's it.

Thank you very much.


Cheers
Jason


- othrayte - 2011-08-01

Background: I'm about to try adding support for scrobbling of streaming items using TraktUtilities and I have been checking what is required, I got ABC iView (I'm in Australia) to stream correctly, and the plugin that provides it has all the info, like title, season, episode, etc. and this is also present in the info screen when the video is being played. At my end TraktUtilities expects the 'data' part of the onPlay json notification to contain relevant data.

When I play a normal episode from my library I get the following json message
{"jsonrpc":"2.0","method":"Player.OnPlay","params":{"data":{"id":2459,"speed":1,"type":"episode"},"sender":"xbmc"}}

But when a streamed video is played as follows:
listitem=xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.thumbnail, thumbnailImage=p.thumbnail)
listitem.setInfo('video', p.get_xbmc_list_item())
xbmc.Player().play(rtmp_url, listitem)

It is important to note that get_xbmc_list_item() provides all of the required info, like title, season, episode, etc.

The json message that results is as follows:
{"jsonrpc":"2.0","method":"Player.OnStop","params":{"data":null,"sender":"xbmc"}}
This on has 'data' set to null

What I want to know is, is it possible for the data passed to xbmc using the listitem to be passed on through the onplay message.

I would think this would make the data useful for most of the streamed data that is played in this way.


- topfs2 - 2011-08-01

othrayte Wrote:What I want to know is, is it possible for the data passed to xbmc using the listitem to be passed on through the onplay message.

I would think this would make the data useful for most of the streamed data that is played in this way.

Well we have had the discussion internally and came to the conclusion that its impossible to tell what information the client wants. The only solution to that problem would either be send everything or just enough to query the server (which we have chosen). The benefit of query is that a client may utilize a cached copy if they so desire, further limiting the bandwith required by json-rpc clients. If the data presented in OnPlay isn't enough to query the server however, that would be a problem (which OnStop seems to lack in your example here, so please make a trac ticket for that). The downside is obviously that it introduces another step or client have to have a cache. However I think its still more clients which might benefit from getting the message as quickly as possible and then choose what to do with it than getting a 50x larger message to parse (number taken from nowhere but might be right Tongue)

There is a third option which would be having clients register what info they want available but that seems to be kindof a hornets nest as they might want different info in OnPlay on movies and episodes, which would make the API cluttered and a lot of extra code on the server.

Hope that explains our design choice and hope you may agree on them Smile I welcome discussion though incase we might have missed anything.

Cheers,
Tobias