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 - Tolriq - 2014-02-03

Thanks for the fix Smile

Since we are in details can you look into this too before final ? Wink

(2013-12-05, 20:31)Tolriq Wrote: Seems like an old bug have come back Smile
Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"musicdb://years/","media":"music","properties":["title","thumbnail","fanart","rating","genre","artist","track","season","episode","year","duration","album","showtitle","playcount","file","mimetype","size","lastmodified"],"sort":{"method":"label","order":"ascending"}}}
returns
Code:
{"id":1,"jsonrpc":"2.0","result":{"files":[{"album":"","artist":[],"duration":0,"fanart":"","file":"musicdb://years/1958/","filetype":"directory","genre":[],"label":"1958","mimetype":"x-directory/normal","playcount":0,"rating":0,"size":0,"thumbnail":"","title":"","track":0,"type":"song","year":1958},{"album":"","artist":[],"duration":0,"fanart":"","file":"musicdb://years/1959/","filetype":"directory","genre":[],"label":"1959","mimetype":"x-directory/normal","playcount":0,"rating":0,"size":0,"thumbnail":"","title":"","track":0,"type":"song","year":1959},{"album":"","artist":[],"duration":0,"fanart":"","file":"musicdb://years/1961/","filetype":"directory","genre":[],"label":"1961","mimetype":"x-directory/normal","playcount":0,"rating":0,"size":0,"thumbnail":"","title":"","track":0,"type":"song","year":1961},{"album":"","artist":[],"duration":0,"fanart":"","file":"musicdb://years/1963/","filetype":"directory","genre":[],"label":"1963","mimetype":"x-directory/normal","playcount":0,"rating":0,"size":0,"thumbnail":"","title":"","track":0,"type":"song","year":1963}
The type is back from unknown to song Smile This may affect quite some cases in both video and audio library as before.



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2014-02-07

Some Files.GetDirectory weirdness Smile

It seems the directory param is somehow case sensitive but not totally.
Let's say you have a source configured as C:\xx

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"C:\\xx\\","media":"video","properties":["resume"]}}

Will return the correct resume value for the media

but

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"c:\\xx\\","media":"video","properties":["resume"]}}

Will return 0 as resume and empty other fields.
(And in the listing all media have a c:\xx\... path)

This should either work in both case, or gives an error when using the wrong case but right now it's quite disturbing and may make some devs loosing hairs and time Wink

And another detail (or not) :

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"c:\\xx\\","properties":["resume"]}}

Same query without specifying a media type will not return the resume property at all while it should return an empty / 0 one.
Since we should be able to assume that when we request a field and the query is successful the answer should have all the requested fields.


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

(2014-02-07, 12:10)Tolriq Wrote: Some Files.GetDirectory weirdness Smile

It seems the directory param is somehow case sensitive but not totally.
Let's say you have a source configured as C:\xx

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"C:\\xx\\","media":"video","properties":["resume"]}}

Will return the correct resume value for the media

but

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"c:\\xx\\","media":"video","properties":["resume"]}}

Will return 0 as resume and empty other fields.
(And in the listing all media have a c:\xx\... path)

This should either work in both case, or gives an error when using the wrong case but right now it's quite disturbing and may make some devs loosing hairs and time Wink

And another detail (or not) :

Code:
{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory":"c:\\xx\\","properties":["resume"]}}

Same query without specifying a media type will not return the resume property at all while it should return an empty / 0 one.
Since we should be able to assume that when we request a field and the query is successful the answer should have all the requested fields.

I'll have to look into the virtual filesystem code of XBMC as JSON-RPC simply passes the directory on to that. Maybe there is some path comparison in the JSON-RPC code though. My guess is that there is a path/file based database query which is always case sensitive and will therefore most likely fail and then you don't get any details from the database.

Concerning the missing "resume" property: What happens if you e.g. specify media as "videos" and ask fro the "mood" property (which only exists for albums/songs)? The problem right now is probably that when not specifying any media type (which defaults to "files") it completely bypasses the logic to handle requested properties except for a select few which make sense for files. That way the request can be handled faster.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2014-02-07

Well the problem is that you request a property get an OK answer but do not get the property it should be sent back as null or empty but should be present.

(This is typically the case when requesting resume for getdirectory on a bad case folder, we do get an resume back with 0 / 0 but at least the field is here even if internally Xbmc has not queried the database to get the value)

Anyway requesting videos and mood + album + albumartist will return album:"" but no mood or albumartist field.

Not very consistent either Sad

Edit : And yes media = files should continue to not query database Smile This is mandatory to browse big directory on things like rPi Wink
Just a matter of field returned empty instead of no fields


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

Yes you get "album" because it is a property for musicvideos but "mood" or "albumartist" isn't so it isn't handled in the video logic and that's why you don't get it in the response.


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

Any plans on implementing pvr recordings? I read a post a couple of months ago, it was a post frode thing.. but I haven't read any of it since. I would love to show recordings in my jquery mobile webapp on my phone, and select a recording for playback.
Currently i'm using argustv rest api to create a list of the recordings, i can playback a recording to, but my webapp needs to take care of setting a recording to watched etc.

Talking to xbmc json and argus tv api is a workaround but not ideal.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2014-02-10

New little thing Smile

Pin code protected dialog locks EventServer and Http server when displayed.
While if I remember there's some dialog that locks Http server this is the first time I see EventServer locked you can not even send a back to dismiss it Sad And needs to have a keyboard.

Furthermore the keyboard arrows are disabled so even if you show the number pad you can only click the numbers and not move with they keys as in all other dialogs.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2014-02-12

I'm trying to get the last 10 movies from a smart playlist by using limits and sort properties but I get an error :

Code:
17:27:59 T:7100   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetMovies", "params": {"directory": "special://profile/playlists/video/Action.xsp", "media": "video", "properties": ["title"], "limits": {"end": 10}, "sort": {"order": "descending", "method": "dateadded"}}}
17:27:59 T:7100   DEBUG: JSONRPC: Calling videolibrary.getmovies
17:28:00 T:7100   DEBUG: Random and Last items script: [RandomAndLastItems] JSON RESULT {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': {u'message': u'Too many parameters', u'method': u'VideoLibrary.GetMovies', u'stack': {u'property': {u'type': u'string', u'name': u'order'}, u'type': u'object', u'name': u'sort'}}}}

Does XSP files are not supported with sort parameter ?

Running XBMC 12.3 on Windows 7.


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

Uhm you're using the wrong method. It needs to be Files.GetDirectory and not VideoLibrary.GetMovies when using an XSP.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2014-02-13

Sorry, wrong Copy / Paste from skin widget python code :S

But error still occur :

Code:
10:07:36 T:4308   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Files.GetDirectory", "params": {"directory": "special://profile/playlists/video/Action.xsp", "media": "video", "properties": ["title"], "limits": {"end": 10}, "sort": {"order": "descending", "method": "dateadded"}}}
10:07:36 T:4308   DEBUG: JSONRPC: Calling files.getdirectory
10:07:37 T:4308   DEBUG: Random and Last items script: [RandomAndLastItems] JSON RESULT {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': {u'message': u'Too many parameters', u'method': u'Files.GetDirectory', u'stack': {u'property': {u'type': u'string', u'name': u'order'}, u'type': u'object', u'name': u'sort'}}}}

And Files.GetDirectory does not support limits parameter ?

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jez500 - 2014-02-13

Hi guys,

I have been working on a web interface for a while now ( here if your interested: http://forum.xbmc.org/showthread.php?tid=183451 )
and have been able to get pretty damn far with the jsonrpc (browser audio streaming, local playlists, soundcloud integration). It is awesome Smile
During this time I have become very fluent with the api, but there are a few things that either don't exist, I'm doing it wrong or looking in the wrong place. So I thought I'd ask..

1. Closing osd dialogs - now and again I may trigger something with the api that causes a dialog to open on screen, most common is "Failed playback" due to a library entry with a path to a invalid file, but also input dialogs (eg. search). When these are open, I seems to prevent any other api calls getting through and I need to go over to the host running xbmc and physically click the close button. So my question basically is, does anyone know of ways to avoid this? eg. allow the api to still do calls while a dialog is open, with search boxes I can send text with Input.SendText and it closes them but, error dialogs seem to kill at least, most commands.

2. Callback on input osd dialogs opening - I have only really tested this with the soundcloud addon so the issue may lay there, however just in case... When I navigate to a path using Files.GetDirectory, if that causes an input dialog to open on screen, the api returns success prior to the dialog opening, meaning I cannot reliably chain events eg. Files.GetDirectory > Input.SendText (leaving me back at issue 1)

3. Persistent storage - I am pretty sure this is a feature request however I might have just missed it too. I would love a way to save/retrieve some data on the host via the api. something like storage System.setVariable {key: value} and System.getVariable {key}. I have heaps of cool ideas if such a thing existed (eg. web ui settings, who played that song and many more ). Any suggestions?

4. "file" property missing when calling AudioLibrary.GetSongDetails in frodo (12.3 stable) - Pretty sure this is a bug and have seen it briefly mentioned in other threads, It works in gotham and also retrieving a songs via AudioLibrary.GetSongs but not when grabbing just one song with AudioLibrary.GetSongDetails, I have found dirty workarounds but it comes at a performance hit. Any plans on fixing this or should I just wait for gotham stable?

Thanks in advance!


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - claymic - 2014-02-13

Hi,
Is there a way to get the lastplayed Season of a TvShow ? I saw that i can get the lastplayed for Tv Shows and Episodes, but not for Seasons. Any tip ?
Thanks in advance.
Clayton


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - ace5342 - 2014-02-14

for some reason I can't delete this post?


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

(2014-02-13, 11:05)mikebzh44 Wrote: Sorry, wrong Copy / Paste from skin widget python code :S

But error still occur :

Code:
10:07:36 T:4308   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Files.GetDirectory", "params": {"directory": "special://profile/playlists/video/Action.xsp", "media": "video", "properties": ["title"], "limits": {"end": 10}, "sort": {"order": "descending", "method": "dateadded"}}}
10:07:36 T:4308   DEBUG: JSONRPC: Calling files.getdirectory
10:07:37 T:4308   DEBUG: Random and Last items script: [RandomAndLastItems] JSON RESULT {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': {u'message': u'Too many parameters', u'method': u'Files.GetDirectory', u'stack': {u'property': {u'type': u'string', u'name': u'order'}, u'type': u'object', u'name': u'sort'}}}}

And Files.GetDirectory does not support limits parameter ?

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory
What version of XBMC are you using? The "limits" parameter for Files.GetDirectory is only available in recent gotham nightly builds but not in Frodo.

(2014-02-13, 14:58)jez500 Wrote: 1. Closing osd dialogs - now and again I may trigger something with the api that causes a dialog to open on screen, most common is "Failed playback" due to a library entry with a path to a invalid file, but also input dialogs (eg. search). When these are open, I seems to prevent any other api calls getting through and I need to go over to the host running xbmc and physically click the close button. So my question basically is, does anyone know of ways to avoid this? eg. allow the api to still do calls while a dialog is open, with search boxes I can send text with Input.SendText and it closes them but, error dialogs seem to kill at least, most commands.
That's a known issue. Ideally most JSON-RPC actions would not trigger any GUI dialogs at all. Furthermore JSON-RPC should still be usable while dialogs are open but at least all Player methods don't work anymore. Have you tried using Input.ExecuteAction with the "back" action?

(2014-02-13, 14:58)jez500 Wrote: 2. Callback on input osd dialogs opening - I have only really tested this with the soundcloud addon so the issue may lay there, however just in case... When I navigate to a path using Files.GetDirectory, if that causes an input dialog to open on screen, the api returns success prior to the dialog opening, meaning I cannot reliably chain events eg. Files.GetDirectory > Input.SendText (leaving me back at issue 1)
Yes this is a problem on how XBMC works internally. It's great for GUI stuff but not for JSON-RPC but all code was written for GUI stuff so JSON-RPC currently runs into these problems.

(2014-02-13, 14:58)jez500 Wrote: 3. Persistent storage - I am pretty sure this is a feature request however I might have just missed it too. I would love a way to save/retrieve some data on the host via the api. something like storage System.setVariable {key: value} and System.getVariable {key}. I have heaps of cool ideas if such a thing existed (eg. web ui settings, who played that song and many more ). Any suggestions?
I don't understand what exactly you are after.

(2014-02-13, 14:58)jez500 Wrote: 4. "file" property missing when calling AudioLibrary.GetSongDetails in frodo (12.3 stable) - Pretty sure this is a bug and have seen it briefly mentioned in other threads, It works in gotham and also retrieving a songs via AudioLibrary.GetSongs but not when grabbing just one song with AudioLibrary.GetSongDetails, I have found dirty workarounds but it comes at a performance hit. Any plans on fixing this or should I just wait for gotham stable?
There will be no more fixes for Frodo. You'll have to wait for the next stable release (i.e. Gotham).

(2014-02-13, 22:39)claymic Wrote: Hi,
Is there a way to get the lastplayed Season of a TvShow ? I saw that i can get the lastplayed for Tv Shows and Episodes, but not for Seasons. Any tip ?
Thanks in advance.
Clayton
You'll have to get the lastplayed episode of a tvshow and then determine the season from there (which is just a property of the episode).


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

(2014-02-16, 17:13)Montellese Wrote:
(2014-02-13, 11:05)mikebzh44 Wrote: Sorry, wrong Copy / Paste from skin widget python code :S

But error still occur :

Code:
10:07:36 T:4308   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Files.GetDirectory", "params": {"directory": "special://profile/playlists/video/Action.xsp", "media": "video", "properties": ["title"], "limits": {"end": 10}, "sort": {"order": "descending", "method": "dateadded"}}}
10:07:36 T:4308   DEBUG: JSONRPC: Calling files.getdirectory
10:07:37 T:4308   DEBUG: Random and Last items script: [RandomAndLastItems] JSON RESULT {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': {u'message': u'Too many parameters', u'method': u'Files.GetDirectory', u'stack': {u'property': {u'type': u'string', u'name': u'order'}, u'type': u'object', u'name': u'sort'}}}}

And Files.GetDirectory does not support limits parameter ?

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory
What version of XBMC are you using? The "limits" parameter for Files.GetDirectory is only available in recent gotham nightly builds but not in Frodo.

I was using Frodo 12.3. I will test Gotham as soon as possible.

Thanks.