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)



- Montellese - 2011-11-12

yallah Wrote:Hi,

Is it possible control dreambox plugin (tuxbox) with JSON
No JSON-RPC doesn't allow access to plugins (yet).

jimk72 Wrote:Im starting to work on the playlist part of my program and noticed the result does not give you a limits like most other results. Is this a bug or is it supposed to be like this. Just trying to figure out how many playlists there are. Or do I have to call a diff method that will tell me how many playlists there are.

Thanks in advanced!

After messing with this I realized that it always returns only those three playlist ids. I am trying to access the playlists created by the user and the name of said playlist.

After researching I found the playlist only access the current players que. I see no JSON in the rpc that will access these. am I right to gather these are not accessable?
Yes you are right, these are not accessible yet because you wouldn't be able to do anything with them. The Playlist namespace is responsible for loaded playlists only and user-generated playlists like Smartplaylists aren't loaded by default. In the future there will be VideoLibrary.GetPlaylists and AudioLibrary.GetPlaylists and a method in the Playlist namespace to load these playlists but currently that's not possible.

othrayte Wrote:I have been using the JSONRPC.NotifyAll method recently, and it has been working fine but I've just tried to use it to pass data and the only thing that it is passing is a string representation of the basic types; ie a string is passed as a string, a number is passed as a string but more complex types like dictionaries, list and tuples are passed as empty strings. In the .json file it specifies that 'data' can be of type 'any'. Should I be able to pass the more complex types and why are the numbers converted to strings?

The example I'm trying is:
Code:
{"params": {"message": "TraktUtilities.View", "data": {"window": "watchlistMovies"}, "sender": "TraktUtilities"}, "jsonrpc": "2.0", "method": "JSONRPC.NotifyAll", "id": 1}

I'll have to try this myself. I haven't used the NotifyAll method in months.


- Montellese - 2011-11-12

othrayte Wrote:I have been using the JSONRPC.NotifyAll method recently, and it has been working fine but I've just tried to use it to pass data and the only thing that it is passing is a string representation of the basic types; ie a string is passed as a string, a number is passed as a string but more complex types like dictionaries, list and tuples are passed as empty strings. In the .json file it specifies that 'data' can be of type 'any'. Should I be able to pass the more complex types and why are the numbers converted to strings?

The example I'm trying is:
Code:
{"params": {"message": "TraktUtilities.View", "data": {"window": "watchlistMovies"}, "sender": "TraktUtilities"}, "jsonrpc": "2.0", "method": "JSONRPC.NotifyAll", "id": 1}

You were right it was really bugged. Thanks for the report. Fixed in https://github.com/xbmc/xbmc/commit/6248d9db4498d5d92719371c9ce8d48cebda8858 so should be available in tomorrow's nightly build.


- Tolriq - 2011-11-12

I'm starting to update Yatse to last Eden since JSON changes are slowing a little Smile

I've got a small question about Player.Open.
What is the real way to use it ?

For the moment for audio albums for example i build playlist then I send a simple :
Quote:JSONCMD : Player.Open - {"item":{"playlistid":1}}

But in XBMC logs it generates lots of warning :
Quote:11:23:12 T:4652 WARNING: JSONRPC: Missing property "file" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "directory" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "movieid" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "episodeid" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "musicvideoid" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "artistid" in type
11:23:12 T:4652 WARNING: JSONRPC: Missing property "albumid" in type

Do i really need to pass all those args ? What value should i use for them then ?

Reading more the logs during writing it seems perhaps the warning are generated by :
Quote:JSONCMD : Playlist.Add - {"item":{"songid":12},"playlistid":1}

But the question remain Smile


- Montellese - 2011-11-12

Tolriq Wrote:I'm starting to update Yatse to last Eden since JSON changes are slowing a little Smile

I've got a small question about Player.Open.
What is the real way to use it ?

For the moment for audio albums for example i build playlist then I send a simple :


But in XBMC logs it generates lots of warning :


Do i really need to pass all those args ? What value should i use for them then ?

Reading more the logs during writing it seems perhaps the warning are generated by :


But the question remain Smile

You either create a playlist and then use the "playlistid" property of the "item" parameter or you just use the "albumid" property of the "item" parameter. The warnings in the log are wrong and I'll see about removing them.

EDIT: I just made a commit that changes the level of those log messages from WARNING to DEBUG so if you don't have debug logging enabled you won't see them at all and if you do they shouldn't be alarming. Actually if there is something wrong with the parameters in your requests you will get an error response from JSON-RPC stating exactly what the problem is (which parameter, what type etc) so you don't really need to look into your log for any syntax-related JSON-RPC request problems.


- Tolriq - 2011-11-12

Thanks for the quick feedback.


- grywnn - 2011-11-12

Me again Rolleyes

Bug?
When i use Playlist.Swap and the position of the currently playing item changes, Player.getProperties doesn't reflect the changes afterwards.

Example:
Currently playing item 2 of playlist 0.
Now i swap item 1 and 2.
The item formerly known as item 2 continues to play, but is now on position 1.
But Player.getProperties will still return position 2.
This goes as far that even the music playlist on XBMCs screen reflects the swap, but highlights the wrong track.


- replenish - 2011-11-12

Hi All,

Currently running an XBMC nightly build (specifically xbmc-20111110-26cc297-master-i386) to try and build a webinterface plugin using the new JSON-RPC API.

I appear to be having an issue with the VideoLibrary.GetSeasons method call.

In the result set I expect an array of seasons which contains properties specified for Video.Details.Season in the API but I only ever seem to get an array of seasons containing the seasons labels and no other properties.

Is the JSON-RPC API fully implemented in the nightly builds yet or am I missing something?

Cheers.


- jasonvp - 2011-11-12

grywnn Wrote:Me again Rolleyes

Bug?
When i use Playlist.Swap and the position of the currently playing item changes, Player.getProperties doesn't reflect the changes afterwards.

Example:
Currently playing item 2 of playlist 0.
Now i swap item 1 and 2.
The item formerly known as item 2 continues to play, but is now on position 1.
But Player.getProperties will still return position 2.
This goes as far that even the music playlist on XBMCs screen reflects the swap, but highlights the wrong track.

Hi grywnn,

This has been discussed before but I haven't submitted a bug ticket for it yet. You can if you like. Wink

jasonvp Wrote:I'm trying to use "Playlist.Swap" (in a similar way to "Move item" in the Context Menu) to move the currently playing song to another position. The problem is if say the currently playing song is at "position:6" and is moved to "position:0" the song moves correctly but the Playlist Position stays the same i.e. "position:6" instead of "position:0" (this is true in the GUI and "Player.GetProperties" results) so the next song to play is "position:7" instead of "position:1".

The reason I use this is because when a Playlist is active and I use "Player.Shuffle" I want the currently playing song to go to "position":0 like it should.

Is this a bug or should there be a "Playlist.MoveItem" method added as well?

http://forum.xbmc.org/showthread.php?tid=68263&page=138


Cheers
Jason


- Montellese - 2011-11-12

replenish Wrote:Hi All,

Currently running an XBMC nightly build (specifically xbmc-20111110-26cc297-master-i386) to try and build a webinterface plugin using the new JSON-RPC API.

I appear to be having an issue with the VideoLibrary.GetSeasons method call.

In the result set I expect an array of seasons which contains properties specified for Video.Details.Season in the API but I only ever seem to get an array of seasons containing the seasons labels and no other properties.

Is the JSON-RPC API fully implemented in the nightly builds yet or am I missing something?

Cheers.

In general all the GetFoo methods only return some very basic properties of the items. If you want more properties you need to specify them in your request. So if you e.g. the "tvshowid" and the "season" property for every returned season you need to specify that in the "properties" parameter of your request.
Code:
{ "jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": { "tvshowid": <some-id>, "properties": [ "season", "tvshowid" ] }, "id": 1 }
This is to minimize the returned data so that everyone can request exactly the properties he needs and no more.


- replenish - 2011-11-12

That makes total sense, just checked that out and it worked a treat thanks for the quick reply!


- jimk72 - 2011-11-12

Montellese Wrote:No JSON-RPC doesn't allow access to plugins (yet).


Yes you are right, these are not accessible yet because you wouldn't be able to do anything with them. The Playlist namespace is responsible for loaded playlists only and user-generated playlists like Smartplaylists aren't loaded by default. In the future there will be VideoLibrary.GetPlaylists and AudioLibrary.GetPlaylists and a method in the Playlist namespace to load these playlists but currently that's not possible.

I can access the playlists through vfs/special://masterprofile/playlists/music/ then parse these and dynamicly create a playlist through json or just using notifications send the next song when the prev ends. Will this folder with the playlists continue to be avail after eden?

Using this method I can have my program load other type playlists and compare song names and artists to send play commands to xbmc this will prob be the best solution till then.


- RedsGT - 2011-11-13

I'm currently trying to replace some HTTP API code with JSON-RPC. Right now the code uses 'QueryVideoDatabase' to get the directory(s) of a tv show based on it's title and then used 'XBMC.updatelibrary(video, <directory>)' to initiate a library update based solely on that directory(s).

1. I've been trying to replicate this using ' VideoLibrary.GetTVShows', the problem being there is no way currently to filter the shows based on the various 'Video.Fields.TVShow' fields. Is asking for filter capability on this method a worthwhile feature request, or is there a better way to go about doing this (like just filtering client side)?

2. With 'XBMC.updatelibrary' from the HTTP API, I could update a single shows directory(s). Would it be a worthwhile feature request to ask for this functionality to be built into 'VideoLibrary.Scan'?


- Montellese - 2011-11-13

RedsGT Wrote:I'm currently trying to replace some HTTP API code with JSON-RPC. Right now the code uses 'QueryVideoDatabase' to get the directory(s) of a tv show based on it's title and then used 'XBMC.updatelibrary(video, <directory>)' to initiate a library update based solely on that directory(s).

1. I've been trying to replicate this using ' VideoLibrary.GetTVShows', the problem being there is no way currently to filter the shows based on the various 'Video.Fields.TVShow' fields. Is asking for filter capability on this method a worthwhile feature request, or is there a better way to go about doing this (like just filtering client side)?

2. With 'XBMC.updatelibrary' from the HTTP API, I could update a single shows directory(s). Would it be a worthwhile feature request to ask for this functionality to be built into 'VideoLibrary.Scan'?

IIRC there are feature requests for both of your points. Currently you'll have to do client side filtering but we are planning to provide filtering based on the SmartPlaylist filtering. The second isn't possible right now at all.


- pilluli - 2011-11-13

Hello,

I am trying to get all movies from the database that have resume bookmarks set using JSON in pre-eden. I am trying to call "VideoLibrary.GetMovies" but I seem unable to succeed.

Is this currently possible or do I need to retrieve all movies and then parse the ones with resume positions > 0?

Regards,


- Montellese - 2011-11-13

pilluli Wrote:Is this currently possible or do I need to retrieve all movies and then parse the ones with resume positions > 0?

That's what you'll have to do for now.