JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC

  Thread Rating:
  • 7 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Nuka1195 Online
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #61
this may be fixed as i'm still pre merge.

PHP Code:
postdata '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"type": "video", "directory": "g:/media/trailers"}, "id": "1"}' 

the type parameter does not take affect. the list returns all files including .mov, .tbn, .nfo

http://pastebin.com/cyL1yD6i

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
jez500 Offline
Junior Member
Posts: 4
Joined: Mar 2010
Reputation: 0
Location: Perth, Australia
Post: #62
will something like "VideoLibrary.GetActors" be available?
find quote
Clou42 Offline
Junior Member
Posts: 10
Joined: Mar 2010
Reputation: 0
Post: #63
I'd still really like to see the UpdateLibrary(type, [path]) calls from the WebUI ported.
find quote
skeeter007 Offline
Junior Member
Posts: 15
Joined: May 2005
Reputation: 0
Post: #64
I've spent 2 days trying to debug what's wrong with my app, but I've had no success. I'm using the Android device emulator to make an http post to

http://10.0.2.2/jsonrpc

with the json string:
Code:
{"method":"VideoLibrary.GetTVShows","params":{"fields":["title"]},"id":1,"jsonrpc":"2.0"}

but the post is not going through. xbmc.log shows:
Code:
NOTICE: WebServer: POST | /jsonrpc
INFO: JSONRPC: Recieved a jsonrpc call -
ERROR: JSONRPC: Failed to parse ''.

and the json returned is a parse error, so clearly the post isn't getting through.
I've modified the exact same Android code to post to another web server I have running on a different port, and I can see the post and the json string come through. Is there anything on the xbmc client side that would specifically prevent the Android emulator from posting data to the web server? Also frustrating is that I'm able to easily post to the server using python.
find quote
topfs2 Online
Team-XBMC Developer
Posts: 3,825
Joined: Dec 2007
Reputation: 8
Post: #65
Which version are you running, there was a bug with multiple posts not getting through before but it should be fixed.

Also if you could send me an example apk that would be great (have android here aswell).

Cheers,
Tobias

If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
find quote
topfs2 Online
Team-XBMC Developer
Posts: 3,825
Joined: Dec 2007
Reputation: 8
Post: #66
Nuka1195 Wrote:this may be fixed as i'm still pre merge.

PHP Code:
postdata '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"type": "video", "directory": "g:/media/trailers"}, "id": "1"}' 

the type parameter does not take affect. the list returns all files including .mov, .tbn, .nfo

http://pastebin.com/cyL1yD6i

Seems like I have that problem aswell, will fix.

Cheers,
Tobias

If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
find quote
skeeter007 Offline
Junior Member
Posts: 15
Joined: May 2005
Reputation: 0
Post: #67
topfs2 Wrote:Which version are you running, there was a bug with multiple posts not getting through before but it should be fixed.

Also if you could send me an example apk that would be great (have android here aswell).

Cheers,
Tobias

I'm running the latest build from here: http://mirrors.xbmc.org/nightlies/win32/

The unsigned apk is here: http://cid-28cada7590855901.skydrive.liv...^_list.apk

And here's where I make the post call:
Code:
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        String host = "http://10.0.2.2";
        int port = 80;
        InputStream is = null;
        
        try {
            String connectionString = host + "/jsonrpc";
            URL u = new URL(connectionString);
            HttpURLConnection conn = (HttpURLConnection) u.openConnection();
            conn.setAllowUserInteraction(false);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            String jsonString = "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetTVShows\", \"params\": {\"fields\":[\"title\"]},\"id\": 1}";
            wr.write(jsonString);
            wr.flush();
            wr.close();
            is = conn.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));
            String line;
            StringBuilder sb = new StringBuilder();
            while ((line = rd.readLine()) != null) {
                sb.append(line);
            }
            System.out.println("breakpoint");
        } catch (IOException e) {
            e.printStackTrace();
        //} catch (JSONException e) {
            // TODO Auto-generated catch block
        //    e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException ioe) {
                // just going to ignore this one
            }
        }
    }

Thanks for any help you can provide. This is driving me nuts! Confused
find quote
skeeter007 Offline
Junior Member
Posts: 15
Joined: May 2005
Reputation: 0
Post: #68
Whoops...completely my fault. I didn't have the latest build installed on my desktop. I've got 4 systems in the house and it's tough to keep track of xbmc across all of them!
Blush
find quote
skeeter007 Offline
Junior Member
Posts: 15
Joined: May 2005
Reputation: 0
Post: #69
The new json methods are awesome- so much more lightweight than the previous xml stuff. Easier to parse, too.

I'm also curious about the tcp socket implementation. Is that documented anywhere? Will the server support websockets or something similar for push notifications?
find quote
topfs2 Online
Team-XBMC Developer
Posts: 3,825
Joined: Dec 2007
Reputation: 8
Post: #70
not sure what you mean by websockets but the tcp server can announce stuff like the old httpapi could, i.e. playback stopped and such.

I've also added so a client can announce stuff aswell, so 2 clients can in theory communicate through this, however the communication is easily eavesdropped by a third client Smile I mostly added it so a script could listen to events and report stuff, a reasonable usage scenario is the social aspect were a script could report love status and such, and since scripts can announce a backend script could easily announce "download finished" and so on.

If there exist interest I'll add a real messaging system which can't be eavesdropped (well with wireshark it could, I doubt I'll add encryption, seems abit more like the clients doing but could be pursuaded to do add though).

P.S Glad to see you got it working.

Cheers,
Tobias

If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
find quote
Post Reply