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)



- pilophae - 2010-12-03

Most of my files' filenames are in UTF-8, but some are apparently in cp850 and latin1 and those are not transcoded to UTF-8 when sent, since they are already 8-bit encodings without BOMConfused.

I thought I had changed all the filenames to UTF-8 already, in which case I shouldn't have received cp850 encoded strings from XBMC. Purely an error on my part.


- giftie - 2010-12-04

Sorry for interrupting but I think I have an example of this happening:

when I make the following call from python:

Code:
json_songs_detail_query = '{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": {"albumid": %s}, "id": 1}' % albumid
json_songs_detail = xbmc.executeJSONRPC(json_songs_detail_query)
print json_songs_detail

I get the following xbmc.log report:

Code:
{
               "id" : 1,
               "jsonrpc" : "2.0",
               "result" : {
                   "end" : 14,
                   "songs" : [
                     {
                        "file" : "/media/freenas/MP3 Music/Full Albums/Stray Cats/02_Stray Cats/02_Live/02_Live At Rockpalast (K ln, 16 July)_1981/Audio/01 - Sweet Love on My Mind.mp3",
                        "label" : "Sweet Love on My Mind",
                        "songid" : 14938,
                        "thumbnail" : "special://masterprofile/Thumbnails/Music/4/4acc11e6.tbn"
                      },

the inportant part of the feedback is:

"file" : "/media/freenas/MP3 Music/Full Albums/Stray Cats/02_Stray Cats/02_Live/02_Live At Rockpalast (K ln, 16 July)_1981/Audio/01 - Sweet Love on My Mind.mp3",

the folder is named:

/media/freenas/MP3 Music/Full Albums/Stray Cats/02_Stray Cats/02_Live/02_Live At Rockpalast (Köln, 16 July)_1981/Audio

notice the ' ö '

when I print to the xbmc.log using:

Code:
print repr( json_songs_detail)

the feed back for the file path now becomes:

"file" : "/media/freenas/MP3 Music/Full Albums/Stray Cats/02_Stray Cats/02_Live/02_Live At Rockpalast (K\x94ln, 16 July)_1981/Audio/01 - Sweet Love on My Mind.mp3"

the open space in 'Köln' where the " ö " is suppose to be, becomes \x94 which is the HEX code for " ö " in CP850 not UTF-8(I believe the HEX would be 0xF6)

I'm not sure this is what pilophae is talking about, but I think it does show a CP850 code coming though and is unable to be treated at UTF-8.


- topfs2 - 2010-12-04

pilophae Wrote:Most of my files' filenames are in UTF-8, but some are apparently in cp850 and latin1 and those are not transcoded to UTF-8 when sent, since they are already 8-bit encodings without BOMConfused.

I thought I had changed all the filenames to UTF-8 already, in which case I shouldn't have received cp850 encoded strings from XBMC. Purely an error on my part.

Huh? thought that the filenames encoding was part of the filesystem? i.e. we should get it in the same encoding always, perhaps thats just me missunderstanding. This entire encoding is way beyond me, never really read up on it Smile


- netuno55 - 2010-12-04

Hi, I'm not trying to be annoying, but I just wanted to know if a JSON method for a SendKey or SendAction is going to be implemented before Dharma final? Just wanted to know if I should just use HTTP-API or EventServer for my client for this purpose. In all honesty I would much prefer a nice JSON method Smile


- topfs2 - 2010-12-04

netuno55 Wrote:Hi, I'm not trying to be annoying, but I just wanted to know if a JSON method for a SendKey or SendAction is going to be implemented before Dharma final? Just wanted to know if I should just use HTTP-API or EventServer for my client for this purpose. In all honesty I would much prefer a nice JSON method Smile

Dharma have been in a feature freeze for quite some time...
As stated previously numerous times its on the roadmap.


- koko1967k - 2010-12-05

sWORDs Wrote:I've returned from vacation last weekend and am finishing up my EventServer Client (for Philips Pronto) so I can start on some XBMC EventServer and JSON client developer documentation right after that.

Hi sWORDs,
I am using HTTP_API in my Pronto TSU9600 to control XBMC.
Nothing fancy, just send keyboard commands to XBMC to interact with the GUI.

Could you point me on how to start a simple program in Pronto's JavaScript to upgrade my program to use EventServer?
I mean:
1. how to connect
2. and how to send a keyboard command.

Thanks a lot.


- _Andy_ - 2010-12-09

If i query JSON for a fanrt i get a link to the speacial file system. For example:
special://masterprofile/Thumbnails/Music/4/4acc11e6.tbn
I searched in the database for the field which stores the value.
Maybe it's a litle bit off topic but how do i get the special link via database?
Do you calculate the value or where can i get the link?


- topfs2 - 2010-12-09

_Andy_ Wrote:If i query JSON for a fanrt i get a link to the speacial file system. For example:
special://masterprofile/Thumbnails/Music/4/4acc11e6.tbn
I searched in the database for the field which stores the value.
Maybe it's a litle bit off topic but how do i get the special link via database?
Do you calculate the value or where can i get the link?

You can use Files.Download to get information how to download it. If your accessing over http it is http://IP:PORT/vfs/special://masterprofile/Thumbnails/Music/4/4acc11e6.tbn

The latter part MUST be url encoded.


- KnisterPeter - 2010-12-15

Hi there,

just started with some javascript code using the xbmc jsonrpc interface but I see no way to get around the cross-site-scripting boundaries by the browser, since my app will run on a different server than the xbmc host and I could not use GET for jsonrpc. Posting to a different host is not allowed...

Does I miss something?

Thanks for any help


- topfs2 - 2010-12-15

Your proxy server needs to proxy the jsonrpc calls also, if it does so it should work.


- KnisterPeter - 2010-12-16

I thought so...
Unfortunatelly I don't want to implement a proxy server since javascript and json are a natural fit...
Wouldn't it be great to have the ability to get around a proxy?
This would be an option for modern browsers: https://developer.mozilla.org/En/HTTP_access_control#The_HTTP_response_headers


- KnisterPeter - 2010-12-16

There are two more posibilites:

* Sending a HTML-Form wich is allowed cross-domain, but then I have to include an textarea containing the json string. This textarea requires a name and result in a parameter in the post request
* Using JSONP as protocol above JSONRPC. With this way we need to support GET-Requests to call a method instead of a post.

Any thoughts?


- topfs2 - 2010-12-16

I'm not sure I really see the benefit, proxy the jsonrpc shouldn't be much more than a oneliner in php afaik.

Doing what you say is out of jsonrpc spec, while it won't disturb jsonrpc much it would still require you to write your own client library (since its out of spec).


- KnisterPeter - 2010-12-16

The benefit is on the client side. I could develop a xbmc-client without requiring another server component.
That is useful for at least every non-IT user downloading an app from some appstore. ;-)

IMHO: This would not even disturb the spec but extend it to some degree. And also my first point (adding some http headers to the response) does not even extend the spec but extend the wire protocol (in this case http).


- topfs2 - 2010-12-16

extending outside jsonrpc 2.0 spec is not a good idea, and adding such a feature for (at this point) essentially you, does not make sense to me. I'm all for you proving me wrong but considering how easy it is to proxy it properly (so that it conforms with jsonrpc spec) I don't see a need for a hack.