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)



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2013-09-02

I'm pretty busy in RL so I didn't have the time to update the list of changes in the JSON-RPC API so here it is for the last few months:

Version 6.4.0

April 13th 2013:
Commit: 3098d92aa4c1739fa8baa6102841f73fbc52e95d
Add media parameter to Playlist.Item directory type

Version 6.5.0

May 1st 2013:
Commit: ab74dddc71dcd0b9c18afeb6db4ca7359316014e
Add Favourites namespace

Version 6.5.1

May 3rd 2013:
Commit: 2b458e08378553ff986fe82c5f70059367572c53
fix return value of "volume" property in Application.GetProperties

Version 6.5.2

June 12th 2013:
Commit: d1e3333b5781a2d9b06aee628f9ed179e1350bcd
fix property values returned by Player.GetItem

Commit: 9952d2fa994d99f12193d0905a25d122bf404c70
use "song" as default value for "type" property

Commit: e0ec520d00f61626303a812f1c4dee0517466746
fix "filetype" property being (unexpectedly) returned for Player.GetItem et al.

Version 6.5.3

August 7th 2013:
Commit: 3b07a0205ba498a376214eb5f7e21afda7724e89
fix "mimetype" being empty in Files.GetDirectory

Commit: 0ef065227265d41de6ac7473b8f6f287ccbcefd8
fix "size" property from Files.GetDirectory overflowing and not returning bytes

Version 6.6.0

August 8th 2013:
Commit: 85bfca08835d489877f4fa3bd47b74f1da179e31
Add Profiles namespace


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - iHateMemphiz - 2013-09-03

(2013-08-27, 07:44)Montellese Wrote:
(2013-08-26, 21:59)thica Wrote: Hello,

can't find it in the API reference. Is here a way to direct switch to a TV channel (PVR) using a json command?

Player.Open can take a "channelid" property in the "item" parameter.

Apologies as I'm a beginner here, what would be the correct format for the call via http, I tried this and it failed:

http://192.168.1.148:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22id%22:%20709,%20%22method%22:%20%22Player.Open%22}


with this

{"error":{"code":-32602,"message":"Invalid params."},"id":709,"jsonrpc":"2.0"}

so i messed my parameters up but where?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2013-09-05

First of all there seems to be an invalid character in your URL. Furthermore you didn't pass in any parameters at all. You just call Player.Open with no additional information.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-09-15

Just an FYI but the latest Gotham master build from git (on a Raspberry Pi, OpenELEC) results in an unhandled exception when calling "VideoLibrary.GetSeasons":

Code:
21:33:59 T:2860594256   ERROR: Action - thread TCPServer, Unhandled exception caught in thread process, aborting. auto delete: 0

The precise call (over TCP) is:
Code:
{"jsonrpc": "2.0", "params": {"sort": {"order": "ascending", "method": "season"}, "tvshowid": 169, "properties": ["season", "art"]}, "method": "VideoLibrary.GetSeasons", "id": "libSeasons"}



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2013-09-15

Tried it on my win32 dev machine with several different tvshowid's and didn't see any problems. Any chance to get the exception or stack trace? Can you try the same request without the sorting and/or without the properties to check if one of those is the culprit?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-09-15

There is no stack trace (at least not in xbmc.log - is it written elsewhere?)

Without sorting (but with those same properties), it works fine - no exception.

With sorting, but without properties, it causes an unhandled exception.

So it looks like sorting is the culprit (descending also causes the exception).

It doesn't appear to be specific to any particular tv show, it's the same with every show I have tried. Oh, and I'm using MySQL in case that makes a difference.

This is what I see in xbmc.log with debug enabled:
Code:
22:40:27 T:2861126736   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "params": {"sort": {"order": "ascending", "method": "season"}, "tvshowid": 169}, "method": "VideoLibrary.GetSeasons", "id": "libSeasons"}
22:40:27 T:2861126736   DEBUG: GetStackedTvShowList query: select idShow from tvshow where c00 like (select c00 from tvshow where idShow=169) order by idShow
22:40:27 T:2861126736   DEBUG: RunQuery took 81 ms for 2 items query: SELECT episodeview.c12, path.strPath, tvshowview.c00, tvshowview.c01, tvshowview.c05, tvshowview.c08, tvshowview.c14, tvshowview.c13, seasons.idSeason, count(1), count(files.playCount) FROM episodeview JOIN tvshowview ON tvshowview.idShow = episodeview.idShow JOIN seasons ON (seasons.idShow = tvshowview.idShow AND seasons.season = episodeview.c12) JOIN files ON files.idFile = episodeview.idFile JOIN tvshowlinkpath ON tvshowlinkpath.idShow = tvshowview.idShow JOIN path ON path.idPath = tvshowlinkpath.idPath WHERE tvshowview.idShow = 169 GROUP BY episodeview.c12
22:40:27 T:2861126736   ERROR: Action - thread TCPServer, Unhandled exception caught in thread process, aborting. auto delete: 0
22:40:27 T:2861126736   DEBUG: Thread TCPServer 2861126736 terminating



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-09-16

@Montellese: I've tracked it down to a new performance patch - my bad, should have mentioned I was using additional patches but thought they were "safe". In hindsight, I've no idea why I thought that...

The patch that causes the problem is this one, which is the second of a pair of patches, the first of the pair being this patch which by itself isn't a problem - it's only when both patches are applied that the problem occurs (the second patch won't apply without the first).

I've notified the author of the patches about this clash with JSON and "VideoLibrary.GetSeasons". I don't understand the reason, just that with this "step 2" patch the exception occurs, and without this patch JSON behaves normally. Maybe the JSON code has a dependency on the updated sort methods.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2013-09-16

It's probably not even JSON related, it just crashes in the TCP server thread because that's where the JSON-RPC request is executed and therefore also where the sorting is executed. Have you tried playing around with the sort order for seasons in the GUI?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-09-16

Fair point, however changing the order of Seasons in the GUI works without a problem (I can also change the order of TV Shows, and Episodes via the GUI). So far the only problem I can find is via JSON RPC (not saying it is the problem, just that's where I see it...)


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2013-09-16

Hi.

Is it possible with a simple JSON query to get season poster (and season art) for an episode ?

Thanks.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2013-09-25

Not possible Sad ?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2013-09-25

Guess it's not possible as I found this code in service.skin.widgets :

Code:
def _fetch_seasonthumb(self, tvshowid, seasonnumber):
        json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": {"properties": ["season", "thumbnail"], "tvshowid":%s }, "id": 1}' % tvshowid)
        json_query = unicode(json_query, 'utf-8', errors='ignore')
        json_query = simplejson.loads(json_query)
        if json_query.has_key('result') and json_query['result'].has_key('seasons'):
            for item in json_query['result']['seasons']:
                season = "%.2d" % float(item['season'])
                if season == seasonnumber:
                    thumbnail = item['thumbnail']
                    return thumbnail

And as Martijn did not call this function any more, I guess it cost some CPU time Sad


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Martijn - 2013-09-25

you would need to request it for each episode separate so indeed very time consuming.
not really a problem for one episode but imagine doing that for several playlists with each 20 items


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2013-09-25

Yes, I have understand this problem. Can be improve by looking if season poster has already been fetch with previous episodes returned but you may have to run this query 10 time for huge collection.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - spambus - 2013-09-26

How can you open a tv channel? In some earlier post something was mentioned about Player.Open and channelid with itemHuh

How would an url look like to open a TV channel?

something like this?

http://xbmc:[email protected]:8090/jsonrpc?request={"jsonrpc":"2.0","method":"Player.Open","item":{"channelid":1},"id":1}

but that doesn't work...