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)



- Bram77 - 2010-04-09

The JSON RPC Api hasn't been added to XBMC for XBOX yet, has it?


- topfs2 - 2010-04-10

Bram77 Wrote:The JSON RPC Api hasn't been added to XBMC for XBOX yet, has it?

Nope, I doubt it will tbh. Should be "fairly" simple to add it and use it with the old webserver though since its seperated well in core now. However I think we need to see some clients before anyone gets the energy to port it Smile


- sWORDs - 2010-04-11

topfs2, would that mean that it wouldn't be hard to run JSON-RPC on live 9.11? Then I wouldn't have to run nightly builds or SVN.


- topfs2 - 2010-04-11

sWORDs Wrote:topfs2, would that mean that it wouldn't be hard to run JSON-RPC on live 9.11? Then I wouldn't have to run nightly builds or SVN.

Live is linux so just build latest svn over a live build and you'll have it (might exist ppa aswell, haven't checked tbh).


- stokedfish - 2010-04-11

hey guys, just leaving a reference to this:

http://forum.xbmc.org/showthread.php?tid=70273

so it won't get forgotten...


- sWORDs - 2010-04-12

topfs2 Wrote:Live is linux so just build latest svn over a live build and you'll have it (might exist ppa aswell, haven't checked tbh).

Already did that, but I was looking for a way to just add JSONRPC to 9.11 without running the rest of the svn.


- Tolriq - 2010-04-12

Well since things advance here i try to complete Yatse for JSON Smile

Version tested : SVN 29202

It seems it currently still not support UTF8 Encoded request :
Quote:21:10:23 T:6472 M:1694167040 NOTICE: WebServer: POST | /jsonrpc
21:10:23 T:6472 M:1694167040 NOTICE: WebServer: POST | /jsonrpc
21:10:23 T:6472 M:1694167040 NOTICE: WebServer: POST | /jsonrpc
21:10:23 T:6472 M:1694167040 ERROR: JSONRPC: Failed to parse '{"id":1,"jsonrpc":"2.0","method":"JSONRPC.Ping"}'

And if i encode file in ascii, i can't start the XBMC.Play (using arg : file and the full filename) if the item contain accents .

It give :
Quote:21:08:18 T:572 M:1698738176 ERROR: Playlist Player: skipping unplayable item: 0, path [smb://NAS/Films4/_Films/Ast?rix aux jeux olympiques (Ast?rix aux jeux olympiques) [2008]/Ast?rix aux jeux olympiques.(2008).mkv]

Changing accent to ? so obviously won't work Smile

And any ETA about VideoPlayer.SeekPercentage (and other players :p).

I have not tested yet the musiclibrary part but is full library get without passing argument implemented ? (to not have to list all artist then do 4000 other requests to get all data). (And genreid returned ?)

Edit : And i can't find a way to know if a player is actually playing or paused.

Edit2 : During my test, jsonrpc and webserver stopped to work after starting a movie :
log file : http://pastebin.com/Fc7a0hTB


- topfs2 - 2010-04-13

Tolriq Wrote:Well since things advance here i try to complete Yatse for JSON Smile

Version tested : SVN 29202

It seems it currently still not support UTF8 Encoded request :

I just reinstalled my machine, will try tommorrow but you could try adding a bit of spaces:
{ "jsonrpc": "2.0", "method": "JSONRPC.Ping", "id": 1 }

Tolriq Wrote:And if i encode file in ascii, i can't start the XBMC.Play (using arg : file and the full filename) if the item contain accents .

It give :


Changing accent to ? so obviously won't work Smile

The one inside the play should be utf8. I've altered alot on the play method though but I'll try with the latest head when I have my dev machine running again Smile

Tolriq Wrote:And any ETA about VideoPlayer.SeekPercentage (and other players :p).

Will add tommorrow

Tolriq Wrote:I have not tested yet the musiclibrary part but is full library get without passing argument implemented ? (to not have to list all artist then do 4000 other requests to get all data). (And genreid returned ?)

GetSongs without artistid or albumid and fields for artist and album? Atleast I would think that should cover that need?

Tolriq Wrote:Edit : And i can't find a way to know if a player is actually playing or paused.

Yeah, thats on a "need-to-do"-basis Smile if you pause it will return pause status though Smile

Tolriq Wrote:Edit2 : During my test, jsonrpc and webserver stopped to work after starting a movie :
log file : http://pastebin.com/Fc7a0hTB

Yeah nad noted that aswell, seems to be windows specific though. The whole network goes down, not sure if its jsonrpc or something else.


- Tolriq - 2010-04-13

topfs2 Wrote:I just reinstalled my machine, will try tommorrow but you could try adding a bit of spaces:
{ "jsonrpc": "2.0", "method": "JSONRPC.Ping", "id": 1 }

Well i'm using a framework (Jayrock) can't really control the spacing, but the same req encoded in ascii works perfectly.

topfs2 Wrote:The one inside the play should be utf8. I've altered alot on the play method though but I'll try with the latest head when I have my dev machine running again Smile

Well that was what i was thinking but since i need to encode to ascii the full req before send i can't have the filename in UTF8 Smile

topfs2 Wrote:Will add tommorrow

Thanks

topfs2 Wrote:GetSongs without artistid or albumid and fields for artist and album? Atleast I would think that should cover that need?

Don't understand your answer, but my need is that i replicate the database to have cache about all the rempote media center the use configure. And for the moment all req need at least one filter parameter so i need to do something like 4001 request is you have 4000 artists to get all data.

topfs2 Wrote:Yeah, thats on a "need-to-do"-basis Smile if you pause it will return pause status though Smile

Lol yeah but the remote change the play button to pause according to this state :p hard to send 2 pause to get the state the user won't like the movie stoping every seconds :p

topfs2 Wrote:Yeah nad noted that aswell, seems to be windows specific though. The whole network goes down, not sure if its jsonrpc or something else.

Well only using windows here for the moment, hope it's nothing important.

And again thanks for your reactivity


- spiff - 2010-04-13

Tolriq Wrote:Well i'm using a framework (Jayrock) can't really control the spacing, but the same req encoded in ascii works perfectly.
if that is a litteral request, ascii and utf-8 would be stored in 100% the same way.


- Tolriq - 2010-04-13

Well the framework that works with other JSONRPC server original code is :

Code:
public virtual object Invoke(Type returnType, string method, object args)
        {
            if (method == null)
                throw new ArgumentNullException("method");
            if (method.Length == 0)
                throw new ArgumentException(null, "method");
            if (returnType == null)
                throw new ArgumentNullException("returnType");

            var request = GetWebRequest(new Uri(Url));
            request.Method = "POST";
            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream, Encoding.[b][size=large]UTF8[/size][/b]))
            {
                var call = new JsonObject();
                call["id"] = ++_id;
                call["jsonrpc"] = "2.0";
                call["method"] = method;
                if (args != null)
                    call["params"] = args;
                JsonConvert.Export(call, writer);
            }
            using (var response = GetWebResponse(request))
            using (var stream = response.GetResponseStream())
            using (var reader = new StreamReader(stream, Encoding.UTF8))
                return OnResponse(JsonText.CreateReader(reader), returnType);
        }

To make it work with XBMC JSONRPC server i need to change this to :

Code:
public virtual object Invoke(Type returnType, string method, object args)
        {
            if (method == null)
                throw new ArgumentNullException("method");
            if (method.Length == 0)
                throw new ArgumentException(null, "method");
            if (returnType == null)
                throw new ArgumentNullException("returnType");

            var request = GetWebRequest(new Uri(Url));
            request.Method = "POST";
            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream, Encoding.[b][size=large]ASCII[/size][/b]))
            {
                var call = new JsonObject();
                call["id"] = ++_id;
                call["jsonrpc"] = "2.0";
                call["method"] = method;
                if (args != null)
                    call["params"] = args;
                JsonConvert.Export(call, writer);
            }
            using (var response = GetWebResponse(request))
            using (var stream = response.GetResponseStream())
            using (var reader = new StreamReader(stream, Encoding.UTF8))
                return OnResponse(JsonText.CreateReader(reader), returnType);
        }

Perhaps it's a bom problem or i don't know but if i just change the UTF8 to ASCII is works and it don't when i revert back with the errors seen in the log file.


- spiff - 2010-04-13

my point was that the binary representation of that text is the same in utf-8 and ascii. no multibyte chars there. but yes, as you say, it might be that it adds a bom which throws xbmc off.


- Bram77 - 2010-04-14

I've compiled XBMC from SVN on my Ubuntu x64 machine today. The api is working great!
I'm writing a OOP Javascript library to make developing web applications easier and it's progressing nicely. I've got the JSONSRCP, Player and AudioPlayer namespaces implemented.
Hopefully someone will merge the JSONRPC code with the XBOX branch soon. I don't use any other branch (only for the JS lib now). I'm developing this to motivate 'someone'... Tongue

Will post a link to the google-code repo shortly...


- Bram77 - 2010-04-14

And here it is.... http://code.google.com/p/xbmcweb/source/browse/#svn/trunk/trunk

Far from finished!!


- topfs2 - 2010-04-14

Wow bram77!

Nice work, if you want to fix up the poc webinterface (or a new one) you'd be my favourite Smile