Kodi Community Forum

Full Version: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
No you don't have to change anything, you urlencode the thumbnail value then use http://x.x.x.x:y/image/urlencoded to get the good thumb.

Or the better official way you use File.PrepareDownload but not really needed for thumbs.
Hummm little bit complicate for me,Smile

I will search File.PrepareDownload or urlencoded in the forum.

thx for your help
Ok I use this command to send Json:

{"jsonrpc": "2.0", "method": "audiolibrary.GetAlbums", "params": { "filter": { "artistid": 2 } , "properties": ["thumbnail", "title", "fanart", "artist"] }, "id": 1}

and I received :
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"albums": [
{
"albumid": 6,
"artist": [
"Artistes divers"
],
"fanart": "image://",
"label": "Trouble [CD2]",
"thumbnail": "image://music@Z%3a%5cAkon%20-%20Discography%205%20Albums%5cAkon%20-%20Trouble%20%5b2004%5d%5cCD2%5c01%20%20Akon%20-%20Belly%20Dancer%20%5bBananza%5d%20%5bFeat.%20Kardinal%20Offishall%5d%20%5bRemix%5d.mp3",
"title": "Trouble [CD2]"
},
{
"albumid": 15,
"artist": [
"Artistes divers"
],
"fanart": "image://",
"label": "\"Final Fantasy X-2\" Piano Collections",
"thumbnail": "",
"title": "\"Final Fantasy X-2\" Piano Collections"
}
],
"limits": {
"end": 2,
"start": 0,
"total": 2
}
}
}

Mys server have IP 192.168.2.29 and use default port 8080.

Can you send me command http://x.x.x.x:y/image/urlencoded if i want see thumbnail in my browser for album Trouble [CD2].
come on ... I give you all needed information Smile

I don't know what language you use but you need to do in pseudo code

var url = urlencode("image://music@Z%3a%5cAkon%20-%20Discography%205%20Albums%5cAkon%20-%20Trouble%20%5b2004%5d%5cCD2%5c01%20%20Akon%20-%20Belly%20Dancer%20%5bBananza%5d%20%5bFeat.%20Kardinal%20Offishall%5d%20%5bRemi​x%5d.mp3")

httpget "http://192.168.2.29:8080/image/" + url

Not really complicated
eheh thxxx

Sorry for newb question Smile

will work on that tonight

Use javascript
@yallah if you want JS examples https://github.com/frolick/AWX-Eden/blob...ib.xbmc.js

@Tolriq thanks for having a look to check it over. I thought it was alright but it's easy to go blind on them Wink On the year thing, yes and no. Both of these work:
Code:
{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetTVShows", "params": { "filter":  {"field": "year", "operator": "is", "value": "2010"} } }
Code:
{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetTVShows", "params": { "filter": { "year": 2010 } } }
So with "normal" filter it's an int but, with what I term "advanced" filter, it's a string. Montellese might choose to change that but that's how it is atm Smile
(2012-08-30, 09:38)Millencolin007 Wrote: [ -> ]
(2012-08-30, 06:20)terrylau Wrote: [ -> ]Hi guys, been searching around but can't seem to find the solution. How do I get the actual names of all the playlists? I have 3 saved audio playlists i.e. Playlist 1, Playlist 2 and Playlist 3

Used
Code:
{"jsonrpc":"2.0","method":"Playlist.GetPlaylists","params":{},"id":1}
but only returns
Code:
{"id":1,"jsonrpc":"2.0","result":[{"playlistid":0,"type":"audio"},{"playlistid":1,"type":"video"},{"playlistid":2,"type":"picture"}]}

Used
Code:
{"jsonrpc":"2.0","method":"Playlist.GetProperties","params":{"playlistid":0,"properties":["size","type"]},"id":1}
but only returns
Code:
{"id":1,"jsonrpc":"2.0","result":{"size":20,"type":"audio"}}

Seems like I'm missing some properties or I'm using the wrong methods to get the playlists' labels.

There is no specific json method to retrieve the playlists. The functions are for the "play queue" and not for playlists in xsp or m3u format. But you can get the playlists using Files.GetDirectory:
Code:
curl -d "{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetDirectory\", \"params\" : { \"directory\" : \"special://musicplaylists\" }, \"id\" : 1 }" http://10.0.0.127:8080/jsonrpc

Then you can use Files.GetDirectory on the returned items to get the content of the playlists

Thanks! That works out great and I've managed to extract the labels of the playlists. A few more questions though :

1) Any commands to play the playlist? I've used the following to play
Code:
{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "special://profile/playlists/music/Playlist1.m3u" } }, "id": 1}
and received an OK response but nothing is playing on my XBMC.

2) How do I list out all the songs that are saved under the playlists when I select a particular playlist? I've tried
Code:
{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid":0, "properties": [ {"file":"special://profile/playlists/music/Playlist1.m3u"} ] }, "id": 1}
but I'm getting an error message
Code:
{"error":{"code":-32602,"data":{"method":"Playlist.GetItems","stack":{"message":"value does not match extended type Item.Fields.Base","name":"Item.Fields.Base","property":{"message":"Invalid type object received","type":"string"},"type":"array"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}
Is it true that the Playlist.GetItems only get info from the current playing playlist?

TIA for the help.
(2012-08-31, 17:11)Tolriq Wrote: [ -> ]come on ... I give you all needed information Smile

I don't know what language you use but you need to do in pseudo code

var url = urlencode("image://music@Z%3a%5cAkon%20-%20Discography%205%20Albums%5cAkon%20-%20Trouble%20%5b2004%5d%5cCD2%5c01%20%20Akon%20-%20Belly%20Dancer%20%5bBananza%5d%20%5bFeat.%20Kardinal%20Offishall%5d%20%5bRemi​x%5d.mp3")

httpget "http://192.168.2.29:8080/image/" + url

Not really complicated

I try find prob, i did urlencode... When I use manual file (browse thumbnail via get thumb) and select file I have reply :

"thumbnail": "image://Z%3a%5cREADERJennifer%20Lopez%20-%20Dance%20Again%20The%20Hits%5cJennifer%20Lopez%20-%20Dance%20Again%20The%20Hits%20-%20Front.bmp",

and he works perfectly on Json (I can see picture in my remote). but with Tag inside MP3 nop :/ (inside XBMC it's work but no JSON command).

I think I will come back when I have more experience with Javascript... Smile Thx for your help
Is it just me, or is the 'limit' param not working on Audio- and VideoLibrary.GetRecentlyAdded* .

Code:
{"id":1,"jsonrpc":"2.0","method":"AudioLibrary.GetRecentlyAddedAlbums","params":{"limits":{"start":0,"end":4},"properties":["artist","thumbnail"]}}

In all cases this request returns 25 results. Am I applying the limits the wrong way?
@terrylau : 1) should work check the content of the playlist and / or xbmc debug log.
2) this is normal all the playlist namespace only works with current playlist.
For your needs use the File.GetDirectory on the playlist and you will have the content Smile

@yallah: I think I remember a bug at a moment with images from mp3 tags and not folder images, check this thread and be sure to use last builds, if still present perhaps it's still not corrected so it may worth to open a trac ticket.

@Bram77 : from code this seems normal the limits param is not used Smile only recentsongs have an applied albumlimit.
This may worth a change in behavior or a change in introspect.
(2012-09-01, 02:38)Tolriq Wrote: [ -> ]@terrylau : 1) should work check the content of the playlist and / or xbmc debug log.
2) this is normal all the playlist namespace only works with current playlist.
For your needs use the File.GetDirectory on the playlist and you will have the content Smile

@yallah: I think I remember a bug at a moment with images from mp3 tags and not folder images, check this thread and be sure to use last builds, if still present perhaps it's still not corrected so it may worth to open a trac ticket.

@Bram77 : from code this seems normal the limits param is not used Smile only recentsongs have an applied albumlimit.
This may worth a change in behavior or a change in introspect.

Thanks for your help - I'm almost there Smile Just a bit more ...
1) How do you save the list of Now Playing songs as a playlist?
2) How do you delete a playlist from the list of playlists available?

Been looking around but can't see any methods that are suitable for these operations.
(2012-08-28, 10:02)Jasp Wrote: [ -> ]
(2012-08-26, 07:48)Jasp Wrote: [ -> ]Just wondering if you will provide direct links like Input.Home to Videos, Movies, TV Shows, Music, Weather, Pictures and Programs.

Would come in quite handy when jumping from one medium to another.

I think this got lost in the large posts regarding filtering and sorting....

I'm hoping.... (with fingers crossed) that something similar to the current ActivateWindow() could be implemented.

Perhaps an Input.Movies.Titles - Input.Movies.Genres - Input.Music.Songs - Input.Music.Artists - Input.Music.Albums - Input.Weather etc
I will add an GUI.ActivateWindow() (or something similar) in the future.

(2012-08-28, 17:08)Bram77 Wrote: [ -> ]@Millencolin007 Thanks again Smile. Of course I'd already looked at the official documentation. I thought that maybe there was a workaround that doesn't show in the docs. I guess I'll have to get creative to distinguish between movies and tv shows.

Quote:"/media/Media/Movies/2 days in Paris" is a directory, therefore it works on directory level

This does work for movies, but TV show root and season directories don't have a playcount param. So to determine if a show has no unwatched episodes I'd have to do at least two more request.
Let's say the TVshow root is "Dexter". To figure out if "Dexter" has unwatched episode I'd have to request it's directory content which would result in "Season 1, Season 2, etc.". Every seasons directory content would have to be fetched and analysed too, to conclude if the "Dexter" directory contains unwatched items.
I realize now that I haven't checked if the "Dexter" directory also contains a tvshow ID which I could use to request all TV show data including the number of unwachted episodes. I'm going to check that first Smile.

To clarify... I'm developing a new Android remote. I don't want to implement library mode, relying on Files.GetDirectory only) because I think it's to confusing for a lot of users to have both file and library mode. Files.GetDirectory offers a very nice middle ground by returning library data where available and file/directory data if an item has not been imported to the database. Unfortunately not all data I need is available (yet :-)). I will use the library options to fetch media meta-data (on request).
There should be an "id" and a "type": "tvshow" so you should be able to do a VideoLibrary.GetTVShowDetails call with the value of "id".

(2012-08-28, 21:34)Tolriq Wrote: [ -> ]A small remark about introspect :

Code:
"List.Limits": {
    "type": "object",
    "properties": {
      "start": { "type": "integer", "minimum": 0, "default": 0 },
      "end": { "type": "integer", "minimum": 0, "default": -1, "description": "The number of items in the list being returned" }
    },
    "additionalProperties": false
  },

After not understanding why my code did not work it seems end is really the end and not the number of items we want Smile it perhaps needs a little update of this description.

Edit : And having a default to -1 to mean all but need a value of 0 to mean all from client side is a little disturbing.
Yup that description is wrong. Concerning -1 and 0. -1 does not mean "all" it means "parameter not set" which is the same as if you just don't provide an "end" property in your request.

(2012-08-28, 23:10)seadog Wrote: [ -> ]I'm using the JSON api to update the play counts of movies/tv episodes (I'm updating the trakt utilities script to work with frodo) and even sending multliple setmoviedetails at a time is still really slow, is there a better way to send them to speed it up, or is this operation just inherently slow?
Currently not. Would be nice to integrate some of the filtering functionality I'm adding to FooLibrary.SetFooDetails but I haven't looked into that yet.

(2012-08-29, 13:20)Tolriq Wrote: [ -> ]Another small remark Smile

Shouldn't the streamdetails field return an empty array instead of null to keep consistency when not available ?
This is the only field that can return the null value instead of an empty one of the correct type needing adding more case handling in json streaming parsing.
"streamdetails" is not an array. It's an object which can have a "video", "audio" and "subtitle" property.

(2012-08-29, 15:17)Tolriq Wrote: [ -> ]And an annoying bug with GetArtists, the total field is not correctly filed it's value is set to end.
So no way to know the number or artists.

Seems from code that it misses a few lines :

Code:
HandleFileItemList("artistid", false, "artists", items, param, result, false);

should be
Code:
int size = items.Size();
  if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
    size = (int)items.GetProperty("total").asInteger();
  HandleFileItemList("artistid", true, "artists", items, parameterObject, result, size, false);

And even if I don't use limits on GetGenre from code too I suppose limits are not applied to them.
Thanks I thought I added that code to AudioLibrary.GetArtists but looks like I didn't. Will fix ASAP.

(2012-08-31, 13:01)Tolriq Wrote: [ -> ]Is a Playlist.Move function in the plans ?

Because from what I understand currently we need to do a remove / insert, and while remove is easy, insert needs analysis of previous getItems to then send the correct insert statement depending on the media since we can't just send back the full item.

Or perhaps I missed something ?
Nah you didn't miss something. Playlist support is still awful Confused

(2012-08-31, 15:13)Tolriq Wrote: [ -> ]@yallah : this is normal with last json, you don't have to check the extension returned, you will still get a valid image in png format.

@grywnn : I finally found an easier way Smile I insert a dummy item at the to position from the file of from item so that always work, then I swap the good from item with the dummy item then I delete the dummy item. That way no problem of multiple swaps. (Of course the to position needs adjustment from > to is different than from < to).

But I must also admit that a notification of playlist changed would be cool because those multiple changes makes keeping sync hard to follow in case of problems.
There's a PR that adds playlist notifications. Just didn't have time yet to look at it.
(2012-08-31, 17:34)Mizaki Wrote: [ -> ]@yallah if you want JS examples https://github.com/frolick/AWX-Eden/blob...ib.xbmc.js

@Tolriq thanks for having a look to check it over. I thought it was alright but it's easy to go blind on them Wink On the year thing, yes and no. Both of these work:
Code:
{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetTVShows", "params": { "filter":  {"field": "year", "operator": "is", "value": "2010"} } }
Code:
{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetTVShows", "params": { "filter": { "year": 2010 } } }
So with "normal" filter it's an int but, with what I term "advanced" filter, it's a string. Montellese might choose to change that but that's how it is atm Smile
I'd love to differe between numbers and strings in the "advanced" filter but it's just not possible with the current system/implementation.

(2012-09-01, 00:46)Bram77 Wrote: [ -> ]Is it just me, or is the 'limit' param not working on Audio- and VideoLibrary.GetRecentlyAdded* .

Code:
{"id":1,"jsonrpc":"2.0","method":"AudioLibrary.GetRecentlyAddedAlbums","params":{"limits":{"start":0,"end":4},"properties":["artist","thumbnail"]}}

In all cases this request returns 25 results. Am I applying the limits the wrong way?
Looks like I broke that recently. Will fix ASAP.

(2012-09-03, 03:08)terrylau Wrote: [ -> ]Thanks for your help - I'm almost there Smile Just a bit more ...
1) How do you save the list of Now Playing songs as a playlist?
2) How do you delete a playlist from the list of playlists available?

Been looking around but can't see any methods that are suitable for these operations.
You can't do either of those right now through JSON-RPC.
(2012-09-01, 02:38)Tolriq Wrote: [ -> ]@terrylau : 1) should work check the content of the playlist and / or xbmc debug log.
2) this is normal all the playlist namespace only works with current playlist.
For your needs use the File.GetDirectory on the playlist and you will have the content Smile

@yallah: I think I remember a bug at a moment with images from mp3 tags and not folder images, check this thread and be sure to use last builds, if still present perhaps it's still not corrected so it may worth to open a trac ticket.

@Bram77 : from code this seems normal the limits param is not used Smile only recentsongs have an applied albumlimit.
This may worth a change in behavior or a change in introspect.

Now I understand Smile I use last build (last night) from Xbmc Master. I change tag with thumbnail (real file), work perfectly. I ll wait for fix. Thx for your help

Quote:"streamdetails" is not an array. It's an object which can have a "video", "audio" and "subtitle" property.

So maybe send back an object with empty arrays after :p the thing is that null object in direct json stream parsing is a pain to handle in normal cases Smile

BTW last Frodo builds have great JSON improvements and speed in limits in query is cool too Smile