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)



- billylg - 2011-06-08

Montellese Wrote:"Parse error" indicates, that the json object of your request is not valid. A good place to check your syntax is http://www.jsonlint.com
In this particular case the problem is the backslash in your path which is used as an escape character so you need to add another one in front of it (\\) to escape it.

Hope this helped.

Using the double slash still wouldn't play the audio file, and the syntax check out fine on http://www.jsonlint.com. But as another user has suggested I was able to play the file by adding to AudioPlaylist then play from the AudioPlaylist. Thanks for all the helps guys!


- othrayte - 2011-06-08

Inside the TraktUtilities add-on I had relied on the fact that XBMC's json notifications were separated by '/n' characters but recently these have been removed, was this by design or was it an accident, without these '/n' characters it is much harder to receive the notifications.


- Montellese - 2011-06-08

othrayte Wrote:Inside the TraktUtilities add-on I had relied on the fact that XBMC's json notifications were separated by '/n' characters but recently these have been removed, was this by design or was it an accident, without these '/n' characters it is much harder to receive the notifications.

This has probably changed with the migration from jsoncpp to yajl and therefore the change of JSON writers. What you should do anyway is counting { and }. So a { increases the counter and a } decreases it and everytime you just read a } and the counter is 0 you received a full object which you can parse.


- othrayte - 2011-06-08

Montellese Wrote:This has probably changed with the migration from jsoncpp to yajl and therefore the change of JSON writers. What you should do anyway is counting { and }. So a { increases the counter and a } decreases it and everytime you just read a } and the counter is 0 you received a full object which you can parse.

Ok, I had considered this, I wasn't sure whether the {} could exist within "" , or if it was possible to escape the {} characters; because if so then I would also have to check for those.


- topfs2 - 2011-06-08

othrayte Wrote:Ok, I had considered this, I wasn't sure whether the {} could exist within "" , or if it was possible to escape the {} characters; because if so then I would also have to check for those.

that can happen in theory, so you need to account for that. Most streaming json parsers handles this though


- topfs2 - 2011-06-08

Forgot to say that we could add \n between notifications if we wanted, afaik its not outside the spec. Anything in between the json objects is meant to be thrown away if we have proper parsers.

I do think its better if we don't have anything in between though, as it makes writing parsers easier IMO (don't have to think about throwing away the wrong data). And checking for \n is not that safe at any rate as you could have \n in a string also (very unlikely though).


- prono - 2011-06-08

I use one of the latest builds (PRE-11.0 Git:201105250d1265ed)of XBMC and I'm seeing something that I would expect to be different.

1) If XBMC goes into screen saver mode it stays like that while I send 'Input.Select', 'Input.Up', 'Input.Down', ''Input.Left', 'Input.Right', same for others, most of them, I don't know of any that would cancel the XBMC screensaver.

2) If I send 'XBMC.SetVolume' the volume bar with the new volume setting does not apread. If I send 'XBMC.ToggleMute' the volume bar and the mute sign does apear.

3) Is the behavior described in the below messages as exected? the messages are sent in the same order.

{"method":"XBMC.SetVolume","id":101,"jsonrpc":"2.0","params":{"value":0}}
{"id":101,"jsonrpc":"2.0","result":0}

{"jsonrpc":"2.0","method":"XBMC.ToggleMute","id":100}
{"id":100,"jsonrpc":"2.0","result":100}

Thank you,


- topfs2 - 2011-06-08

volume = 0 is considered mute IIRC, this however is not really sane for json-rpc so I would suggest creating a bugreport.

All of the others seems like valid bugs, input should most likely cancel screensave but not execute the action.


- Montellese - 2011-06-08

As an FYI the "tvshowid" parameter in VideoLibrary.GetEpisodes just became optional with the latest commit. Now you can retrieve all episodes in your library if needed. But beware if you want to use the "season" parameter, you need to define the "tvshowid" parameter as well.


- Montellese - 2011-06-08

And another FYI: There are two new methods available:

- AudioLibrary.GetArtistDetails
- VideoLibrary.GetGenres (thanks to slash2009)

Furthermore we have refactored and renamed the notifications so make sure you check out the new json schema descriptions available from JSONRPC.Introspect in the "notifications" object. Or take a look at the changes in 28743c1647d6cdef84fe.


- othrayte - 2011-06-09

topfs2 Wrote:Forgot to say that we could add \n between notifications if we wanted, afaik its not outside the spec. Anything in between the json objects is meant to be thrown away if we have proper parsers.

I do think its better if we don't have anything in between though, as it makes writing parsers easier IMO (don't have to think about throwing away the wrong data). And checking for \n is not that safe at any rate as you could have \n in a string also (very unlikely though).

Yeah I've gone with some custom code to find the chunks of json that should take into account {} occurring within strings. If anyone is interested it is at 2661473e, which shows the change from basic bracket count chuncking to this new method.


- Montellese - 2011-06-11

Hey everyone

With this commit I just made it is now possible to use an optional "filter" parameter in JSONRPC.Introspect. As the full output of JSONRPC.Introspect is huge and probably a bit overwhelming and confusing I came up with the "filter" parameter which is an object and should contain an "id" and a "method" value.

Here are a few examples of its use:
  • If you only want to retrieve the definition of a single method you can call
    Code:
    { "jsonrpc": "2.0", "method": "JSONRPC.Introspect", "params": { "filter": { "id": "VideoLibrary.GetMovieDetails", "type": "method" } }, "id": 1}
    What you will get as an answer is the JSON Schema definition of the VideoLibrary.GetMovieDetails method + only the JSON Schema type definitions of the types referenced by VideoLibrary.GetMovieDetails.

  • If you don't care about the definition of the referenced types (because you already know them) and only need the bare definition of the method you can call
    Code:
    { "jsonrpc": "2.0", "method": "JSONRPC.Introspect", "params": { "filter": { "id": "VideoLibrary.GetMovieDetails", "type": "method", "getreferences": false } }, "id": 1}
    The "getreferences" attribute (which is enabled by default) lets you define whether you want to see the definition of all the referenced types or not.

  • The same works for type definitions like "List.Sort"
    Code:
    { "jsonrpc": "2.0", "method": "JSONRPC.Introspect", "params": { "filter": { "id": "List.Sort", "type": "type" } }, "id": 1}

  • If you want to see all the methods available in a certain namespace (e.g. AudioPlaylist) you can call
    Code:
    { "jsonrpc": "2.0", "method": "JSONRPC.Introspect", "params": { "filter": { "id": "AudioPlaylist", "type": "namespace" } }, "id": 1}

Use JSONRPC.Introspect to get all the possibilities the new "filter" parameter introduces. Basically you can filter by a method, type, notification or namespace.

I hope this helps in finding out about what parameters to pass to a certain method and what you will get in return.


- xblitz - 2011-06-11

I had submitted a bug a month ago... http://trac.xbmc.org/ticket/11538

I found where the problem is and updated the ticket.. but no one is the owner or in CC of the ticket so I guess no one got notified.. so if you guys can take a look.. would be great Smile I also put suggestions to fixing the bug !


- bartdesign - 2011-06-12

I'm using the latest osx nightly and I'm trying to use the VideoLibraryGetRecentlyAddedEpisodes() to get the newest tv show episodes. But i'm missing a reference back to the tv show itself. Is it possible to get the tv show thumbnail? I've looked through introspect but i can't find an good solution.

It would be nice to have the tvshow id returned with the Library.Fields.Episode. That way it would be easy to get an reference to a show from the recently added episodes. Another way to solve this is to create a function that returns the tvshowid with the episodeid as parameter, but that will create an extra call.


- topfs2 - 2011-06-12

bartdesign Wrote:I'm using the latest osx nightly and I'm trying to use the VideoLibraryGetRecentlyAddedEpisodes() to get the newest tv show episodes. But i'm missing a reference back to the tv show itself. Is it possible to get the tv show thumbnail? I've looked through introspect but i can't find an good solution.

It would be nice to have the tvshow id returned with the Library.Fields.Episode. That way it would be easy to get an reference to a show from the recently added episodes. Another way to solve this is to create a function that returns the tvshowid with the episodeid as parameter, but that will create an extra call.

I'd feature request this on trac, not sure if it is possible (easily) but it does seem like a very valid thing to have.