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)



- Montellese - 2011-10-23

carmenm Wrote:Actually what bugs me most is that the response doesnt follow xbmc json specification. Especially i dont get a "failure" field(which i rely on just to know that XBMC answered correctly).
Moreover, i was watching a movie!

I ll post a complete response example this afternoon.

Thanks for your quick answer.
Why do you expect a "failure" field? First of all I have never heard of a "failure" field in JSON-RPC and second of all your request didn't fail. If no player is playing, that is not an error so an empty array will be returned.

I just tested it on my dev machine and if I'm watching a movie I get
Code:
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": [
    {
      "playerid": 1,
      "type": "video"
    }
  ]
}
which is correct. When I don't have any active players I get
Code:
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": [ ]
}
which is correct as well.


- carmenm - 2011-10-23

I assure you there was a "failure" in XBMC JSON RPC before. My app was working and i wasnt stoned ( at least i hope so Tongue)
So i ll update it taking in account it s not there anymore.

Thanks for the feedback.


- topfs2 - 2011-10-23

carmenm Wrote:Actually what bugs me most is that the response doesnt follow xbmc json specification. Especially i dont get a "failure" field(which i rely on just to know that XBMC answered correctly).
Moreover, i was watching a movie!

I ll post a complete response example this afternoon.

Thanks for your quick answer.

While as montellese states that the response is meant to be either an array of items or the empty array you _always_ need to be aware that methods can fail.

Many methods may fail to execute (a specific jsonrpc error) for various reasons, this is something all clients need to check against and be aware of. While xbmc in general might not fail to execute new servers might (as they might not have implemented all in the API).

For example Player.Pause may fail to execute, its within the spec.


- carmenm - 2011-10-23

topfs2 Wrote:While as montellese states that the response is meant to be either an array of items or the empty array you _always_ need to be aware that methods can fail.

Many methods may fail to execute (a specific jsonrpc error) for various reasons, this is something all clients need to check against and be aware of. While xbmc in general might not fail to execute new servers might (as they might not have implemented all in the API).

For example Player.Pause may fail to execute, its within the spec.

I am sorry but i am not sure i get your point.
Does it mean there WAS a failure field?
I mean how can a client check the success of a jsonrpc if not with a success/failure field?


- topfs2 - 2011-10-23

carmenm Wrote:I am sorry but i am not sure i get your point.
Does it mean there WAS a failure field?
I mean how can a client check the success of a jsonrpc if not with a success/failure field?

Check jsonrpc 2.0 specification, errors are defined there.


- jasonvp - 2011-10-24

Hi guys,

Is there a method for retrieving the location and items of Saved Playlists and Party Mode Playlists?


Cheers
Jason


- Montellese - 2011-10-24

Saved playlists aren't exposed yet but I have already considered something like FooLibrary.GetPlaylists which could be added after Eden has been released. As soon as we have the Playlist.Create/Load/Destroy/Unload functionality such methods make sense because they will allow to load those playlists into a playlist manageable through jsonrpc.

I think this feature request covers your question? If you have something to add to the ticket, feel free to do so. Any input is welcome.


- jasonvp - 2011-10-24

Montellese Wrote:I think this feature request covers your question? If you have something to add to the ticket, feel free to do so. Any input is welcome.

What about adding Favourites to the Ticket or should this be in a new Feature Request Ticket?


- Montellese - 2011-10-24

Does Favourites have anything to do with Playlists? I don't think so, so a new feature request ticket is better.


- jasonvp - 2011-10-24

Montellese Wrote:Does Favourites have anything to do with Playlists? I don't think so, so a new feature request ticket is better.

Yeah your right. Sorry wasn't thinking.Smile


- frolick - 2011-10-26

Howdy,

I have question about the Files.GetDirectory call.

One of my smb sources is set up like:
Code:
smb://user:pswd@ipaddress/folder/share

If I make the following call:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://ipaddress/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

JSON RPC responds with a "Invalid params" error but if I make the same call with the host name of the computer substituted for the IP like below then everything works correctly and I get a list of what's in that directory.
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://hostname/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

I know the simple solution is just to use the hostname instead of the IP in the sources list but I was wondering if Files.GetDirectory was supposed to work with IPs in the directory field or if it just accepts a string with the folder name.

I'm testing on an ATV2 running the 20111024-c5758bf nightly.

Thanks!

Edit: Nevermind. It works if I use smb://user:pswd@ipaddress/folder/share/. I haven't looked into it yet, but is there a way that I'm not seeing to get the full folder location (with user/pswd) from Files.GetSources? Time to call JSONRPC.Introspect


- jimk72 - 2011-10-26

Ok I have my program recieving json now so I am making big jumps. I am having problems with two things.

Where do I figure out the params? I am trying to do Player.open and send a movie from the library json the movieid is 4. I see how to do a playlist item and an actual file but not a library item. When I looked all it says is it can do a playlist, file, picture folder, or database item. I seem to be missing the list of objects and items that are avail to pass as a param.

The second thing is getting the thumbnail images from xbmc. I know how to call for them and get the location but what method are you guys using to download the images to display in your app and what format are they in? PNG?

Thanks for all the help so far!
jimk


- Montellese - 2011-10-26

frolick Wrote:Howdy,

I have question about the Files.GetDirectory call.

One of my smb sources is set up like:
Code:
smb://user:pswd@ipaddress/folder/share

If I make the following call:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://ipaddress/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

JSON RPC responds with a "Invalid params" error but if I make the same call with the host name of the computer substituted for the IP like below then everything works correctly and I get a list of what's in that directory.
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://hostname/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

I know the simple solution is just to use the hostname instead of the IP in the sources list but I was wondering if Files.GetDirectory was supposed to work with IPs in the directory field or if it just accepts a string with the folder name.

I'm testing on an ATV2 running the 20111024-c5758bf nightly.

Thanks!

Edit: Nevermind. It works if I use smb://user:pswd@ipaddress/folder/share/. I haven't looked into it yet, but is there a way that I'm not seeing to get the full folder location (with user/pswd) from Files.GetSources? Time to call JSONRPC.Introspect
There's no other method of retrieving sources apart from Files.GetSources. I'll have to investigate myself why XBMC doesn't return the path with username and password but maybe it's a "security feature". I'll let you know once I found out what's going on.

jimk72 Wrote:Ok I have my program recieving json now so I am making big jumps. I am having problems with two things.

Where do I figure out the params? I am trying to do Player.open and send a movie from the library json the movieid is 4. I see how to do a playlist item and an actual file but not a library item. When I looked all it says is it can do a playlist, file, picture folder, or database item. I seem to be missing the list of objects and items that are avail to pass as a param.
You call JSONRPC.Introspect to get a fully blown documentation of all the methods and parameters available. In case of starting a movie you would call
Code:
{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "movieid": 4 } }, "id": 1 }

jimk72 Wrote:The second thing is getting the thumbnail images from xbmc. I know how to call for them and get the location but what method are you guys using to download the images to display in your app and what format are they in? PNG?
That depends on what transport you are using? Are you using HTTP or TCP? Only HTTP supports file downloads so far. As I just updated the JSON-RPC wiki page you can take a look there to get more detailed information: http://wiki.xbmc.org/index.php?title=JSON_RPC#Comparison
If you use HTTP you call Files.PrepareDownload with the path to the file you'd like to download and then call http://<your-ip>:<your-port>/<path from Files.PrepareDownload> to actually download the file.


- Montellese - 2011-10-26

frolick Wrote:Howdy,

I have question about the Files.GetDirectory call.

One of my smb sources is set up like:
Code:
smb://user:pswd@ipaddress/folder/share

If I make the following call:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://ipaddress/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

JSON RPC responds with a "Invalid params" error but if I make the same call with the host name of the computer substituted for the IP like below then everything works correctly and I get a list of what's in that directory.
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "smb://hostname/folder/share/", "media" : "video", "sort": { "order": "ascending", "method": "file" } }, "id": 1}

I know the simple solution is just to use the hostname instead of the IP in the sources list but I was wondering if Files.GetDirectory was supposed to work with IPs in the directory field or if it just accepts a string with the folder name.

I'm testing on an ATV2 running the 20111024-c5758bf nightly.

Thanks!

Edit: Nevermind. It works if I use smb://user:pswd@ipaddress/folder/share/. I haven't looked into it yet, but is there a way that I'm not seeing to get the full folder location (with user/pswd) from Files.GetSources? Time to call JSONRPC.Introspect

OK I found out that returning source paths without the credentials (username/password) is a security feature. But that doesn't explain why the call to Files.GetDirectory with the ip-based smb path doesn't work. Could you please check the passwords.xml file in your XBMC userdata profiles directory and see if the credentials are stored in there and whether they are stored for the ip-based SMB path or for the hostname-based path?


- jasonvp - 2011-10-26

Hi guys,

Would it be possible to have a search method? E.G. Search and return only songs or what ever that start with the letter A, B, or C etc or word. Like the Search feature in the GUI or is this not possible with json?


Cheers
Jason