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)



- staeff - 2010-12-30

Montellese Wrote:You are missing to correct parameters to the System.GetInfoLabels method. You need to provide an array containing the labels you would like to retrieve
Code:
{ "jsonrpc": "2.0", "method": "System.GetInfoLabels", "params": ["System.CurrentControl", "System.CurrentWindow"], "id": 1 }
would be what you are after (it's not tested so maybe I made a mistake while typing it out of my head).

Thanks! It's working now. Do you know, if and how I can receive all controls of a window?

Edit:
2nd Question: getCurrentWindow() doesn't show the "Videos" - menu name - do you know this problem?


- Montellese - 2010-12-30

staeff Wrote:Do you know, if and how I can receive all controls of a window?
Not that I know of but you can check all available InfoLabels heere: http://wiki.xbmc.org/index.php?title=InfoLabels

staeff Wrote:getCurrentWindow() doesn't show the "Videos" - menu name - do you know this problem?

Uhm what is getCurrentWindow() and what skin are you using?


- staeff - 2010-12-30

Thanks for the link. I'll try the promising ones..

Montellese Wrote:Uhm what is getCurrentWindow() and what skin are you using?

It's just an empty String, and I'm using Confluence - the built in one of the release version.. (I'm going to check some other versions)


- Montellese - 2010-12-30

I actually meant "What do you mean by "getCurrentWindow()?". Where did you find that function or is it even a function?


- staeff - 2010-12-31

Montellese Wrote:I actually meant "What do you mean by "getCurrentWindow()?". Where did you find that function or is it even a function?

Ah, ok. The function just sends a rpc call like this:
Code:
"{"id":497,"jsonrpc":"2.0","method":"System.GetInfoLabels","params":["System.CurrentWindow"]}"

the answer for "videos" is:
Code:
"{
   "id" : 497,
   "jsonrpc" : "2.0",
   "result" : {
      "System.CurrentWindow" : ""
   }
}

here is an answer for "music"
Code:
"{
   "id" : 71,
   "jsonrpc" : "2.0",
   "result" : {
      "System.CurrentWindow" : "Music/Files"
   }
}



- Montellese - 2010-12-31

I have no idea sorry. Maybe an XBMC dev familiar with the skinning engine or a skinner might be able to answer that question.


- bartdesign - 2011-01-01

I've been playing with the VideoLibrary.GetRecentlyAddedEpisodes method. And i've encountered a problem. I need to get the tv show thumbnail instead of the episode thumbnail. But the GetRecentlyAddedEpisodes does not return a show string or an id reference to the tv show. Does XBMC's database carry a reference to the tv show? If so could we add the show id or label in the return array of episodes in the VideoLibrary.GetRecentlyAddedEpisodes method?

Maybe it's already there and i'm overlooking something?


Where to find a list of fields for JSON RPC calls that support the use of fields? - giftie - 2011-01-03

Since JSON RPC is going to replace HTTP API(eventually) and it's ease to parse for information I have been using JSON RPC calls in the scripts I currently am working on. I know it is still in flux as development continues.

I have been looking through the source code for XBMC. I am having a tough time finding the location that would give me an idea of what fields are available for certain JSON RPC calls.

I have found a few by luck and chance. I wouldn't mind helping out documenting JSON RPC calls in the Wiki and even the source code.

All help is appreciated..


- topfs2 - 2011-01-03

giftie Wrote:Since JSON RPC is going to replace HTTP API(eventually) and it's ease to parse for information I have been using JSON RPC calls in the scripts I currently am working on. I know it is still in flux as development continues.

I have been looking through the source code for XBMC. I am having a tough time finding the location that would give me an idea of what fields are available for certain JSON RPC calls.

I have found a few by luck and chance. I wouldn't mind helping out documenting JSON RPC calls in the Wiki and even the source code.

All help is appreciated..

Hopefully we will add this data to the introspect at some point but for now its in CVideoInfoTag::Serialize and CMusicInfoTag::Serialize they can be found in files xbmc/VideoInfoTag.cpp and xbmc/MusicInfoTag.cpp


- giftie - 2011-01-03

topfs2 Wrote:Hopefully we will add this data to the introspect at some point but for now its in CVideoInfoTag::Serialize and CMusicInfoTag::Serialize they can be found in files xbmc/VideoInfoTag.cpp and xbmc/MusicInfoTag.cpp

Awesome.. Thank you very much...


AudioPlaylist.Add does not work properly - vaton4 - 2011-01-03

Code:
{"id" : 5,
  "jsonrpc" : "2.0",
  "result" : {
    "end" : 3,
    "items" : [
      {
        "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/7735abc0.tbn",
        "file" : "D:/someMusic/someAlbum/someFile.flac",
        "label" : ""
      },{
        "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/7735abc0.tbn",
        "file" : "D:/someMusic/someAlbum/someFile.flac",
        "label" : "someFile.flac"
      },{
        "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/7735abc0.tbn",
        "file" : "D:/someMusic/someAlbum/somefile.flac",
        "label" : "D:/someMusic/someAlbum/someFile.flac"
      }
    ],
    "start" : 0,
    "total" : 3
  }
}
What you see is the reply of JSONRPC command:

Code:
{"jsonrpc":"2.0", "method":"AudioPlaylist.GetItems", "id":5}
All three items should be equal as they point to the same file - just added by different commands.
As you can see, they are not. Comparing each other, I get quite different "label" parts.

First item is result of the JSONRPC command:
Code:
{"jsonrpc":"2.0", "method":"AudioPlaylist.Add", "params": {"file": "D:/someMusic/someAlbum/someFile.flac"}, "id":1}
Second item is result of the xHTTP command:

Code:
command=AddToPlayList(D:/someMusic/someAlbum/;0;[Music];1)
where directory D:/someMusic/someAlbum/ contains the file of interest.

Third item is result of the xHTTP command:
Code:
command=AddToPlayList(D:/someMusic/someAlbum/someFile.flac;0;[Music];1)
BMHO the only correct version is the second one.

Further, command:
Code:
{"jsonrpc":"2.0", "method":"AudioPlaylist.Add", "params": {"file": "D:/someMusic/someAlbum/"}, "id":1}
Does not add contents of directory (as expected), just directory itself:
Code:
{"id" : 5,
  "jsonrpc" : "2.0",
  "result" : {
    "end" : 1,
    "items" : [
      {
        "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/477af51b.tbn",
        "file" : "D:/someMusic/someAlbum/",
        "label" : ""
      }
    ],
    "start" : 0,
    "total" : 1
  }
}
Any suggestions?


mixed encodings in filenames - grywnn - 2011-01-04

I've just run into an issue concerning filenames.

When doing a VideoLibrary.GetMovies i get (among many others)
Code:
{
            "fanart" : "special://masterprofile/Thumbnails/Video/Fanart/ccffb604.tbn",
            "file" : "/home/xbmc/server/video/german/Haben Sie das von den Morgans gehört (2009)/Haben Sie das von den Morgans gehört (2009).avi",
            "genre" : "Komödie / Drama / Romanze",
            "label" : "Haben Sie das von den Morgans gehört?",
            "movieid" : 56,
            "thumbnail" : "special://masterprofile/Thumbnails/Video/c/ccffb604.tbn",
            "year" : 2009
},

Note that the filename contains a UTF8 char (ö = ö) as well as a ISO char (the "ö" near the end).
This combination kills the Ocj-C JSON parser i'm using (YAJL).
I've implemented a workaround in my client by interpreting the JSON answer as Latin1, and trying to interpret each result string as utf8 afterwards, falling back to the Latin1 encoded result if the conversion to utf8 fails.

Unfortunately i can't really tell wether the problem is located with JSON, with XBMCs filehandling, or maybe even on the filesystem.

Is this known? Maybe even by design?

Edit:
Just found the same issue was discussed a few pages earlier. Damn, this thread is getting long...


- litemotiv - 2011-01-05

I'm having a lot of trouble doing a simple rpc call with mootools javascript. Hopefully someone can shed some light.

This is my basic request:

Code:
jsonRequest = new Request.JSON(
{
    'url': '/jsonrpc',
}).post(
{
    'jsonrpc': '2.0',
    'method': 'Files.GetSources',
    'id': 1,
    'params':
    {
        'media': 'video'
    }
});

It errors out with a parse error, so something must be malformed, but i can't figure out what. I've tried with and without params, putting them in an array and whatnot, but i keep getting the same result.

Any ideas?


- Montellese - 2011-01-05

I replaced all ' with " and sent the request over TCP and it worked (with ' it failed). But I don't know what mootools does with the json object you provide.

EDIT: Just checked the json specification and it says strings must be delimited by ".
Quote:A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes



- litemotiv - 2011-01-05

Montellese Wrote:I replaced all ' with " and sent the request over TCP and it worked (with ' it failed). But I don't know what mootools does with the json object you provide.

EDIT: Just checked the json specification and it says strings must be delimited by ".

Thanks for your reply Montellese. Unfortunately, replacing all the single quotes still gives a parse error.

The mootools request object is also using single quotes internally though, so i'm not sure if there still is a problem there in some way: https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.js