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)



- mikebzh44 - 2012-01-25

Thanks very much for this usefull answer.

I'm running Eden beta 2.


- mikebzh44 - 2012-01-25

I'm trying to query movies database :

Code:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "3.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["file", "fanart", "thumbnail"]}, "id": 1}')

but it raise an error

Code:
JSONRPC: Failed to parse '{"id":1,"jsonrpc":"3.0","method":"VideoLibrary.GetMovies","params":{"properties":["file","fanart","thumbnail"]}}'

Everything is OK vith V2.0 JSONRPC :

Code:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["file", "fanart", "thumbnail"]}, "id": 1}')

Calling method is different ?

Sorry but I'm discovering XBMC, python, XML, ...


- Montellese - 2012-01-25

Hehe the version you provide in "jsonrpc" in your request must be "2.0" and it does not relate to the version of XBMC's JSON-RPC API but the version of the JSON-RPC specification implemented by XBMC. So there's the version for the JSON-RPC implementation (which is "2.0") and the version of XBMC's JSON-RPC API (which currently is 3) but you don't need to specify XBMC's JSON-RPC API as you can't choose between the different versions. If you want to know what version of XBMC's JSON-RPC API you are using, you can call JSONRPC.Version.


- mikebzh44 - 2012-01-25

Sorry, I have misunderstoud the versions.

Now, everything is clear.

Thanks.


- Mizaki - 2012-01-29

Does VideoLibrary.GetMovieSets ignore movie sets that only contain 1 movie?

themoviedb scrapper seems to fetch the set info for movies now. I added a movie that is part of a set. If I retrieve the movie info details I get a setid of 10. GetMovieSets does not return that id. In the DB it is there linked to the movie id as expected.


- Montellese - 2012-01-29

Mizaki Wrote:Does VideoLibrary.GetMovieSets ignore movie sets that only contain 1 movie?

themoviedb scrapper seems to fetch the set info for movies now. I added a movie that is part of a set. If I retrieve the movie info details I get a setid of 10. GetMovieSets does not return that id. In the DB it is there linked to the movie id as expected.

Yes that's how XBMC handles sets. A set only exists if there are at least two movies in it.


- Mizaki - 2012-01-29

That makes sense but should getmoviedetails return a set then? May seem a silly question but this is the problem:

Request movie details.
Returns setid.
Query movie set details by setid.
Errors.

I have to therefore verify the movie set details. Which I can do but seems a little non-intuitive.


- Mizaki - 2012-01-29

I think Files.GetDirectory is getting confused.
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "special://profile/playlists/video/tv.xsp", "media" : "video", "properties": ["artist", "album", "showtitle", "episode", "season"] }, "id": 1}
Just 1 of the results is:
Code:
{"album":"","artist":"","episode":14,"file":"/mnt/nanika/TV2/The Big Bang Theory/","filetype":"directory","id":342,"label":"The Big Bang Theory","season":-1,"showtitle":"The Big Bang Theory","type":"unknown"}
For episode it's reporting 14. That is the number of video files in the directory.

Test playlist is:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="tvshows">
    <name></name>
    <match>all</match>
    <rule field="none" operator="contains"></rule>
    <limit>10</limit>
    <order direction="ascending">random</order>
</smartplaylist>
In case you need it.


- Montellese - 2012-01-29

What are you expecting it to return? For a tvshow or season the "episode" property returns how many episodes the tvshow/season contains.


- Mizaki - 2012-01-29

I'm expecting nothing or -1 like season. It returns the episode number when retrieving an episode.

But if that's correct then season should return the number of seasons? And then being a pendant it should be seasons and episodes.

Also, it'll be incorrect if you have seasons/series folders as GetDirectories isn't recursive.


- Montellese - 2012-01-29

If you don't expect anything why do you even retrieve the values? Compare this with how VideoLibrary.GetTVShows works. It can provide an "episode" field which will return the number of episodes in a tvshow but it does not have a "season" field. That's why you get -1 for "season" but 14 for "episode". We didn't introduce an extra field "episodes" because the meaning is always defined by the type of the item (tvshow, season, episode). Furthermore having "episode" and "episodes" would be prone to hard-to-find typing errors.

EDIT: I just spotted another bug in there. The "type" is returned as "unknown" even though it should be "tvshow". I just fixed it in https://github.com/xbmc/xbmc/commit/18409c3c402c5767d93f0e5f5d41993d8603d913


- Mizaki - 2012-01-29

I retrieve it as a general catch all. I'm using GetDirectories to process a smart playlist which could contain anything (hence the artist and album as well).

No worries, I can ignore it if the type comes back as tvshow. I just thought it was incorrect.


- Montellese - 2012-01-29

Mizaki Wrote:That makes sense but should getmoviedetails return a set then? May seem a silly question but this is the problem:

Request movie details.
Returns setid.
Query movie set details by setid.
Errors.

I have to therefore verify the movie set details. Which I can do but seems a little non-intuitive.

Could you please create a bug report for this problem on trac. I agree that for every setid returned by another JSON-RPC call the call to VideoLibrary.GetMovieSetDetails should return the existing details. But I looked into the code and it's far from an easy fix. The problem lies in the general implementation of sets in XBMC and the fact that sets with only one movie are not considered as such when listing them in the GUI.


- Mizaki - 2012-01-29

http://trac.xbmc.org/ticket/12558 Hopefully it makes sense.


- Tolriq - 2012-01-30

I'm getting quite a strange bug with Xbmc Json android and authentication.

For authentication i use the simple basic way with the Authorization header. (But i got the same result with Authenticator).

If i disable Xbmc auth, all my code works perfect.

If i enable password all standard json requests works ok. But all batch request send a parse error.

The logs in debug shows :

Quote:01:49:42 T:12112 DEBUG: JSONRPC: Incoming request: User-Agent: Dalvik/1.4.0 (Linux; U; Android 2.3.6; GT-I9100 Build/GINGERBREAD)

Host: 192.168.0.11:90

Connection: Keep-Alive

Content-Length: 665

Content-Type: application/x-www-form-urlencoded

Accept-Encoding: gzip
01:49:42 T:12112 ERROR: JSONRPC: Failed to parse 'User-Agent: Dalvik/1.4.0 (Linux; U; Android 2.3.6; GT-I9100 Build/GINGERBREAD)

Host: 192.168.0.11:90

Connection: Keep-Alive

Content-Length: 665

Content-Type: application/x-www-form-urlencoded

Accept-Encoding: gzip



with the exact same code on second earlier :
Quote:01:49:41 T:12112 DEBUG: JSONRPC: Incoming request: {"id":1,"jsonrpc":"2.0","method":"Player.GetActivePlayers"}
01:49:41 T:12112 DEBUG: JSONRPC: Calling player.getactiveplayers

I'm quite lost ... but it looks like a problem with some headers request size and Xbmc.