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)



- carmenm - 2011-04-01

Montellese Wrote:First call "Player.GetActivePlayers" to determine the currently active player (audio, video or picture). If it is audio or video call Audio/VideoPlaylist.GetItems and read the "current" field to get the position of the currently playling item in the playlist. The "items" field contains an array of all items in the playlist and "items[current]" is the currently playing file. You can also tell jsonrpc which fields to return for every item in the playlist and therefore you'll have all the information you need.

Thanks will try that very soon.


- carmenm - 2011-04-03

A question about Files.Download.
Can i assume that all download links are like http://.../vfs/special:....?
I ask because when loading a lot of images it makes it a lot faster instead of having to ask for Files.Download for each image.
For now it seems to be working but the existence of the function Files.Download makes me wonder if it there were some cases where it wouldnt work.

thanks


- topfs2 - 2011-04-03

carmenm Wrote:A question about Files.Download.
Can i assume that all download links are like http://.../vfs/special:....?
I ask because when loading a lot of images it makes it a lot faster instead of having to ask for Files.Download for each image.
For now it seems to be working but the existence of the function Files.Download makes me wonder if it there were some cases where it wouldnt work.

thanks

Well for http you can for sure assume that its like that always. That method is more of a placeholder for transports which may actually need some kindof setup to initiate the download. As an example the raw tcp might want to open a new port where you can stream it from (as ftp does IIRC) or some other protocol might give you the file directly in that method. Point is its meant to be there for transport to handle it as they wish.

HTTP however will always use that style with http.../vfs/something so assume that, I doubt we will ever change that.


- carmenm - 2011-04-03

Ok great. i ll assume then Wink

THanks


- jitterjames - 2011-04-03

I am going to start switching my project (VoxCommando) over to JSON soon. It is written in c# so I am interested in using a .net library if possible.

There appear to be two very similar library projects for XBMC and JSON using .net

http://code.google.com/p/xbmc-json/ (by dstruktiv)

http://sourceforge.net/projects/xbmcjsonsharp/ (by montellese)

my main concern in choosing one of these libraries is that the project stays alive and gets updated to support any changes in the actual JSON interface to xbmc. As I understand it the interface will continue to grow and evolve for some time. Neither of these libraries seems to have been very active so far in 2011. Sad

I am also curious to know if both these libraries connect to xbmc via http, or if one of them uses a direct TCP connection, and if so, is this any faster?

Do both libraries currently offer the same feature set, or is one more complete / up to date?

Whichever one I choose to go with, I will probably want to contribute to the project somewhat once I get a better handle on how all this stuff works. At the moment, I am still a bit overwhelmed with too much information.

Thanks for any advice on this.


- Montellese - 2011-04-03

jitterjames Wrote:I am going to start switching my project (VoxCommando) over to JSON soon. It is written in c# so I am interested in using a .net library if possible.
I recommend to wait a bit because there will be a major change in XBMCs JSON RPC in the next one or two weeks.

jitterjames Wrote:my main concern in choosing one of these libraries is that the project stays alive and gets updated to support any changes in the actual JSON interface to xbmc. As I understand it the interface will continue to grow and evolve for some time. Neither of these libraries seems to have been very active so far in 2011. Sad
I can only speak for my part but
1. There were no real changes in the JSON RPC API in that period.
2. I was/am working on XBMC's JSON RPC API itself and there will be some huge changes so I didn't see any reason why to update a soon-to-be "deprecated" library.
3. I'm mostly interested in improving XBMC's side of JSON RPC but I plan on updating my library as soon as the changes are available.

jitterjames Wrote:I am also curious to know if both these libraries connect to xbmc via http, or if one of them uses a direct TCP connection, and if so, is this any faster?
My library offers the choice between HTTP and TCP BUT it always uses TCP to receive Announcements anyway.

jitterjames Wrote:Do both libraries currently offer the same feature set, or is one more complete / up to date?
No idea what dstruktiv's library supports but my library supports almost anything (AFAIK only the sorting possibility is missing and maybe a few announcements) but I don't support .NET Microframework so if you want to make a mobile remote you'll have to go with dstruktiv's work.

jitterjames Wrote:Whichever one I choose to go with, I will probably want to contribute to the project somewhat once I get a better handle on how all this stuff works. At the moment, I am still a bit overwhelmed with too much information.
I would welcome someone who would be willing to give me a hand.


- jitterjames - 2011-04-03

OK. Thanks for the quick response. I will wait then, and keep an eye on this thread. I assume that you'll be making announcements here when the features are rolled out. I have been holding off anyway since I find the JSON commands to be pretty limited. There is still a lot that I can't do with it, which means I'll probably end up with a mish mash of eventClient, http api, and json commands.Sad

In the mean time, if someone could point me to the latest nightly that has proper support for the latest version of JSON I would appreciate it.

I was trying to use this one from april second:
http://mirrors.xbmc.org/nightlies/win32/XBMCSetup-20110402-0c66478-master.exe

and getting very stange results, but thought it was just me being stupid...

when I tried another machine running xbmc 10.1 things seemed to behave much better. Maybe 10.1 has the latest implementation of JSONRPC anyway?


- Montellese - 2011-04-03

jitterjames Wrote:OK. Thanks for the quick response. I will wait then, and keep an eye on this thread. I assume that you'll be making announcements here when the features are rolled out.
Yes there will be a proper announcement providing detailed information about what has been changed etc.

jitterjames Wrote:In the mean time, if someone could point me to the latest nightly that has proper support for the latest version of JSON I would appreciate it.

I was trying to use this one from april second:
http://mirrors.xbmc.org/nightlies/win32/XBMCSetup-20110402-0c66478-master.exe

and getting very stange results, but thought it was just me being stupid...

Can you be more specific about what you mean with "very strange results"?


- jitterjames - 2011-04-04

Montellese Wrote:Can you be more specific about what you mean with "very strange results"?
Yeah, sure, sorry. For testing I'm using Ithe "simple rest client" plugin in chrome.

With the xbmc nightly build, there doesn't appear to be any indentation on the results that are returned. That is just a clue that something is different, but not necessarily breaking anything. With xbmc 10.1 it comes back all nicely indented.

Now for the true bug... With the nightly, if I call a method that has optional fields, XBMC seems to be returning all fields anyway.

for example with this command:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 100, "sortorder":"ascending", "fields": ["genre","year"] }, "id": 1}
it returns all fields, not just the defaults + genre + year.

If you want I can do another test and provide more information, logs, or screen-captures, but to do it I'll have to reinstall a nightly build, since I've now gone back to 10.1

While I'm on the topic, why does this command return the fanart, filename, and thumbnail, even if we don't ask for it? ID and label I can understand, but the rest seems wasteful, especially if I'm asking for a list of all items.

with the above command, using 10.1 I get this result:
Code:
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "end" : 43,
      "movies" : [
         {
            "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/8d34bf81.tbn",
            "file" : "D:\\Movies\\The Incredibles\\The Incredibles (2004).avi",
            "genre" : "Animation / Action / Adventure / Family / Fantasy",
            "label" : "The Incredibles",
            "movieid" : 14,
            "thumbnail" : "special://masterprofile/Thumbnails/Video/8/8d34bf81.tbn",
            "year" : 2004
         },
...
...



- Montellese - 2011-04-04

jitterjames Wrote:With the xbmc nightly build, there doesn't appear to be any indentation on the results that are returned. That is just a clue that something is different, but not necessarily breaking anything. With xbmc 10.1 it comes back all nicely indented.
Ah that's a feature I have added since the Dharma release. You can switch it back to the old behaviour with an advanced setting (see http://wiki.xbmc.org/index.php?title=Advancedsettings.xml#.3Cjsonrpc.3E). The general idea is to minimize the amount of unnecessary data transfered. This is especially useful for devices with very limited RAM like Smartphones etc.

jitterjames Wrote:Now for the true bug... With the nightly, if I call a method that has optional fields, XBMC seems to be returning all fields anyway.

for example with this command:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 100, "sortorder":"ascending", "fields": ["genre","year"] }, "id": 1}
it returns all fields, not just the defaults + genre + year.
Hm seems to be working for me. I ran the exact same request you posted and it returned the following fields for every movie: file, genre, label, movieid, thumbnail, year.
I just tested it on a nightly build from late March and the very newest one from April 3rd and it works as expected.

jitterjames Wrote:While I'm on the topic, why does this command return the fanart, filename, and thumbnail, even if we don't ask for it? ID and label I can understand, but the rest seems wasteful, especially if I'm asking for a list of all items.
That is a very good question and I don't know the answer. "fanart" should already be optional using "fields" but I don't know why "thumbnail" is always returned. Please create a feature request ticket on Trac for this so I don't forget about it.


- jitterjames - 2011-04-04

OK, I installed the april 3rd and it seems to be ok now. I don't know if there was a problem with the april 2nd, or if installing 10.1 and then installing april 3rd 'fixed' something.

Once I figure out how to submit a trac ticket I will. For the record, I think that "file" should not be returned by default either, since we don't always want it and it can be quite a long string. But I will put that on my ticket.

Thanks


- marksoccer - 2011-04-04

Is there currently a way to get the artist bio of an artist by artistid? I'm looking for a way to get the text listed under description for artist information. It looks like I could use, a system info label to get the bio of the currently playing artist, but I'd like to be able to view non-playing artists as well.


- carmenm - 2011-04-04

Montellese Wrote:I recommend to wait a bit because there will be a major change in XBMCs JSON RPC in the next one or two weeks.

You are scaring me. Is that a change we already have on nitghly build? CAn you give little more info about it?


- Montellese - 2011-04-04

marksoccer Wrote:Is there currently a way to get the artist bio of an artist by artistid? I'm looking for a way to get the text listed under description for artist information. It looks like I could use, a system info label to get the bio of the currently playing artist, but I'd like to be able to view non-playing artists as well.
IIRC this isn't possible yet, neither with Dharma nor with the latest nightlies but it will be available soon.

carmenm Wrote:You are scaring me. Is that a change we already have on nitghly build? CAn you give little more info about it?
No need to be scared Wink This change isn't in the nightly builds yet as it is currently being reviewed before it will be available in the nightly builds. As soon as that happens there will be detailed information about what has changed.


- carmenm - 2011-04-04

ok just saw your fork Wink will take a look at it to see whats coming Tongue