• 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 226
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
#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/
Reply
#62
will something like "VideoLibrary.GetActors" be available?
Reply
#63
I'd still really like to see the UpdateLibrary(type, [path]) calls from the WebUI ported.
Reply
#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.
Reply
#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

"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#."
Reply
#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

"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#."
Reply
#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! Huh
Reply
#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
Reply
#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?
Reply
#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

"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#."
Reply
#71
Hey,

Great to see an overhaul being made of the Web API. I'm a little late to the party it seems, but the progress made on the JSON interface looks nice and clean!

I spent about 30 minutes with it on the iPhone remote, just starting down the path of implementing a few basic calls and in that time came across some things I found / had thoughts on:

URL
- Found the URL has to be /jsonrpc rather than /jsonrpc/ . Though when accessing either from the web browser as a GET it gives a 'File not found' error. Be nice we could access from either both paths or /jsonrpc gave an error to suggest it's the correct one to hit but requires POST data to submit. Just took me a couple of mins to figure out why I was getting no response,

System.GetInfo
- Is this intended to be synonymous with the HTTP API GetSystemInfo ?
- Wondering if there is any way to get the info we used to be able to get from the GetSystemInfo command (maybe with a seperate command), such as the XBMC version and shuffle state (though see next point).

Playlist.XXX
- Can we get some methods to get the playlist state ? Such as Shuffle and Repeat status.

MusicLibrary.GetGenres
- Can this be implemented ?

MusicLibrary.GetArtists
- Crashing when passing genreid (if assuming I'm doing the correct thing)


Code:
{"jsonrpc":"2.0","params":{"genreid":"6"},"id":"1","method":"MusicLibrary.GetArtists"}

Code:
Thread 5 Crashed:
0   libSystem.B.dylib                 0x97cfa732 __kill + 10
1   libSystem.B.dylib                 0x97cfa724 kill$UNIX2003 + 32
2   libSystem.B.dylib                 0x97d8d98d raise + 26
3   libSystem.B.dylib                 0x97da39d9 __abort + 124
4   libSystem.B.dylib                 0x97da3a55 abort_report_np + 0
5   libstdc++.6.dylib                 0x94001fda __gnu_cxx::__verbose_terminate_handler() + 433
6   libstdc++.6.dylib                 0x9400017a __cxxabiv1::__terminate(void (*)()) + 10
7   libstdc++.6.dylib                 0x940001ba __cxxabiv1::__unexpected(void (*)()) + 0
8   libstdc++.6.dylib                 0x940002b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0
9   com.teamxbmc.xbmc                 0x0087286f Json::Value::asInt() const + 271
10  com.teamxbmc.xbmc                 0x00884a2a JSONRPC::CMusicLibrary::GetArtists(CStdStr<char> const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*, Json::Value const&, Json::Value&) + 186

Cheers,
Dave Fumberger.
Reply
#72
narcan Wrote:Hey,

Great to see an overhaul being made of the Web API. I'm a little late to the party it seems, but the progress made on the JSON interface looks nice and clean!

Thanks for the compliments.
narcan Wrote:I spent about 30 minutes with it on the iPhone remote, just starting down the path of implementing a few basic calls and in that time came across some things I found / had thoughts on:

URL
- Found the URL has to be /jsonrpc rather than /jsonrpc/ . Though when accessing either from the web browser as a GET it gives a 'File not found' error. Be nice we could access from either both paths or /jsonrpc gave an error to suggest it's the correct one to hit but requires POST data to submit. Just took me a couple of mins to figure out why I was getting no response,

Well tbh I don't think there is any convention to what url to post, Problems with allowing both is more that it could get confusing Smile

Anyways on the topic of GET, I doubt its in specification to handle it but I like the idea very much, I'll make it so on a GET of the correct URL will return an introspect or something usefull atleast.

narcan Wrote:System.GetInfo
- Is this intended to be synonymous with the HTTP API GetSystemInfo ?
- Wondering if there is any way to get the info we used to be able to get from the GetSystemInfo command (maybe with a seperate command), such as the XBMC version and shuffle state (though see next point).

Well the system is really against system underneath xbmc, i.e. osx and such. its abit confusing and perhaps the whole namespace should get revamped, however adding version and such I'll for sure do in XBMC.Foo

narcan Wrote:Playlist.XXX
- Can we get some methods to get the playlist state ? Such as Shuffle and Repeat status.

Sure, I'm planning on doing a big revamp on the playlist handling soon so consider it subject to change (mostly thinking of splitting out active and nonactive playlists to seperate namespaces, i.e. VideoPlaylist.Shuffle and then have Playlist.GetItems(id ="/foo/bar.m3u") )

narcan Wrote:MusicLibrary.GetGenres
- Can this be implemented ?

I really want it in, there is some problems with xbmc core regarding genre IDs I need to overcome, will look at it asap!

narcan Wrote:MusicLibrary.GetArtists
- Crashing when passing genreid (if assuming I'm doing the correct thing)


Code:
{"jsonrpc":"2.0","params":{"genreid":"6"},"id":"1","method":"MusicLibrary.GetArtists"}

Code:
Thread 5 Crashed:
0   libSystem.B.dylib                 0x97cfa732 __kill + 10
1   libSystem.B.dylib                 0x97cfa724 kill$UNIX2003 + 32
2   libSystem.B.dylib                 0x97d8d98d raise + 26
3   libSystem.B.dylib                 0x97da39d9 __abort + 124
4   libSystem.B.dylib                 0x97da3a55 abort_report_np + 0
5   libstdc++.6.dylib                 0x94001fda __gnu_cxx::__verbose_terminate_handler() + 433
6   libstdc++.6.dylib                 0x9400017a __cxxabiv1::__terminate(void (*)()) + 10
7   libstdc++.6.dylib                 0x940001ba __cxxabiv1::__unexpected(void (*)()) + 0
8   libstdc++.6.dylib                 0x940002b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0
9   com.teamxbmc.xbmc                 0x0087286f Json::Value::asInt() const + 271
10  com.teamxbmc.xbmc                 0x00884a2a JSONRPC::CMusicLibrary::GetArtists(CStdStr<char> const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*, Json::Value const&, Json::Value&) + 186

Cheers,
Dave Fumberger.

Well tbh the whole genre stuff in jsonrpc is just there as a placeholder, I really should remove or fix so it works Smile genreid needs to be an int but IIRC it doesn't even work if you specify the correct ID.

Thank you for the valuable ideas.

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

"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#."
Reply
#73
Ok, I've had a serious redo of many of the jsonrpc calls in r29062 -> r29085.

Here are a number of the highlights.

MusicPlayer -> AudioPlayer.

NowPlaying playlist are now managed in AudioPlaylist and VideoPlaylist, essentially just switch Playlist(id = "video") to VideoPlaylist and it will work the same.

Playlist can now handle playlists from disk and virtual ones (this is still in the works so the api is subject to change big time).

Python can access jsonrpc with xbmc.executeJSONRPC.

Players and playlists will have add and such that can take more than just a file, for instance webinterface now uses AudioPlaylist.Play("albumid" = X) to add and autoplay an album from musiclibrary (It might get moved to AudioPlayer.Play instead, not decided but the idea will exist somewere). Also you can use this in AudioPlaylist.Add and it will be possible to use in Playlists and such aswell. So AudioPlaylist.Add("playlist-virtual" = "foo") works.

[Music|Video]Library.ScanForContent is added.

I've made so you can get the /jsonrpc in http to check if json is available (if its compiled in).

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

"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#."
Reply
#74
Hi,

I just did a little addition to your ScanForContent method to allow an optional "path" parameter. I have four hard-drives in my HTPC and a normal Update will spin up all drives so I always use the version when adding something to the library.

As it is a quite trivial patch I didn't know if opening a trac ticket is appropiate, so I pasted the diff here.

I'd be glad if you could include it in the next version. Maybe for the Audio-Library as well.

Keep up the great work
Demian
Reply
#75
edit running 29135 solved my problems.
Reply
  • 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 226

Logout Mark Read Team Forum Stats Members Help
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC8