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)



- jasonvp - 2011-10-19

Montellese Wrote:Hm I tried playing a view movies and executed your jsonrpc request and the returned fanart path was always correct. Does this problem occur with every video you play?

This is for TV Shows. I only have one Show in XBMC at the moment just to make it easier to test things.

When I use "VideoLibrary.GetTVShows", "VideoLibrary.GetTVShowDetails" and "VideoLibrary.GetSeasons" for Fanart I get "special://masterprofile/Thumbnails/Video/Fanart/307790e7.tbn" for all of them which is correct but when use "Playlist.GetItems" and "Player.GetItem" I get "special://masterprofile/Thumbnails/Video/Fanart/9e82215b.tbn" which does not exist. "Thumbnails/Video/9/auto-9e82215b.tbn" does exist but this is the Thumbnail.

I also deleted the .tbn files and downloaded them again but the same thing happens. Huh

Cheers
Jason


- mad-max - 2011-10-19

Hey guys,

im struggling with the JSON stuff...basically I wanted an addon that queues the selected audio file and then make a skip to the next track...
I found the appropriate commands in the wiki, but have no clue how to structure my addon...

here is the original thread in the python section:
http://forum.xbmc.org/showthread.php?tid=112742

would be great if somebody could take a look and give me a hint how to do syntax and stuff...

cheers,
mm


- Montellese - 2011-10-19

jasonvp Wrote:This is for TV Shows. I only have one Show in XBMC at the moment just to make it easier to test things.

When I use "VideoLibrary.GetTVShows", "VideoLibrary.GetTVShowDetails" and "VideoLibrary.GetSeasons" for Fanart I get "special://masterprofile/Thumbnails/Video/Fanart/307790e7.tbn" for all of them which is correct but when use "Playlist.GetItems" and "Player.GetItem" I get "special://masterprofile/Thumbnails/Video/Fanart/9e82215b.tbn" which does not exist. "Thumbnails/Video/9/auto-9e82215b.tbn" does exist but this is the Thumbnail.

I also deleted the .tbn files and downloaded them again but the same thing happens. Huh

Ah that stupid fanart at episode level problem again. This is a more or less known problem. The reason why it happens is that there is no fanart at episode level but only at tv show level so if someone requests fanart for an episode we have to do some extra work to retrieve it. It didn't work at the beginning, then it was partly fixed but it still doesn't work 100%. Best way to get the fanart for an episode is to retrieve the "tvshowid" property and then query VideoLibrary.GetTVShowDetails() with that "tvshowid" to retrieve the fanart.

mad-max Wrote:Hey guys,

im struggling with the JSON stuff...basically I wanted an addon that queues the selected audio file and then make a skip to the next track...
I found the appropriate commands in the wiki, but have no clue how to structure my addon...

here is the original thread in the python section:
http://forum.xbmc.org/showthread.php?tid=112742

would be great if somebody could take a look and give me a hint how to do syntax and stuff...

As I don't have any clue about python coding I'm not sure what you are after. I can only provide help when it comes down to what you can do with jsonrpc and how you can do it best/easiest. Btw beware, the current documentation on the wiki is outdated and many methods have been moved/renamed. I'll try to update it ASAP.


- mad-max - 2011-10-19

Montellese Wrote:As I don't have any clue about python coding I'm not sure what you are after. I can only provide help when it comes down to what you can do with jsonrpc and how you can do it best/easiest. Btw beware, the current documentation on the wiki is outdated and many methods have been moved/renamed. I'll try to update it ASAP.

Thanks for taking time montelesse...yes, maybe you can help me interpreting the error message i'm getting while using the JSON-RPC...

My Code:
Code:
import xbmc

AddToPlaylist = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "id": 1, "params": {"item": {"songid": 7}}}')

if AddToPlaylist["result"] == "OK":
  xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.SkipNext", "id": 1}')

And the error:
Code:
21:04:09 T:2504  NOTICE: -->Python Interpreter Initialized<--
21:04:09 T:2504   ERROR: Error Type: <type 'exceptions.TypeError'>
21:04:09 T:2504   ERROR: Error Contents: string indices must be integers, not str
21:04:09 T:2504   ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.playlistenhancer\default.py", line 5, in <module>
                                                if AddToPlaylist["result"] == "OK":
                                            TypeError: string indices must be integers, not str

thanks for your help...

mm


- Montellese - 2011-10-19

mad-max Wrote:Thanks for taking time montelesse...yes, maybe you can help me interpreting the error message i'm getting while using the JSON-RPC...

My Code:
Code:
import xbmc

AddToPlaylist = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "id": 1, "params": {"item": {"songid": 7}}}')

if AddToPlaylist["result"] == "OK":
  xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.SkipNext", "id": 1}')

And the error:
Code:
21:04:09 T:2504  NOTICE: -->Python Interpreter Initialized<--
21:04:09 T:2504   ERROR: Error Type: <type 'exceptions.TypeError'>
21:04:09 T:2504   ERROR: Error Contents: string indices must be integers, not str
21:04:09 T:2504   ERROR: Traceback (most recent call last):
                                              File "C:\Users\max\AppData\Roaming\XBMC\addons\script.playlistenhancer\default.py", line 5, in <module>
                                                if AddToPlaylist["result"] == "OK":
                                            TypeError: string indices must be integers, not str

thanks for your help...

mm

Like I said the jsonrpc documentation on the xbmc wiki is heavily outdated. What version of XBMC are you using? In the latest nightly builds there is no "AudioPlaylist" anymore. But as soon as I know what version (Dharma 10.0/10.1 or pre-eden (ideally with the git commit hash) of XBMC you are using I can provide more detailed information.

Best way to get a full documentation is to call JSONRPC.Introspect. That will return a list of all available methods, their parameters and what they return.


- mad-max - 2011-10-19

Montellese Wrote:Like I said the jsonrpc documentation on the xbmc wiki is heavily outdated. What version of XBMC are you using? In the latest nightly builds there is no "AudioPlaylist" anymore. But as soon as I know what version (Dharma 10.0/10.1 or pre-eden (ideally with the git commit hash) of XBMC you are using I can provide more detailed information.

Best way to get a full documentation is to call JSONRPC.Introspect. That will return a list of all available methods, their parameters and what they return.

Ok, there might bethe problem...I try AudioPlaylist but in my nightly from today there is no audioplaylist...

will substitute this with only "playlist" and see what's going on...

mm


- jasonvp - 2011-10-20

Montellese Wrote:Ah that stupid fanart at episode level problem again. This is a more or less known problem. The reason why it happens is that there is no fanart at episode level but only at tv show level so if someone requests fanart for an episode we have to do some extra work to retrieve it. It didn't work at the beginning, then it was partly fixed but it still doesn't work 100%. Best way to get the fanart for an episode is to retrieve the "tvshowid" property and then query VideoLibrary.GetTVShowDetails() with that "tvshowid" to retrieve the fanart.

Thanks Montellese.


- jimk72 - 2011-10-22

Im implementing json control im my touchscreen remote program I am building and I have no means of returning json at this moment am only implementing sending commands using tcp port 9090. Is there any where in my install that I may find a list of current commands for the build I am using(oct 20). Or is there a post I can put into IE that will return the list?
Or is there any return from tcp/udp transfers on a certain port I can look for or is the returns http only at this time?

I have been so frustrated trying to implement this and then I realised I had 5 diff builds on my various pcs and mediaplayers. All up to date at this point Smile


- Montellese - 2011-10-22

jimk72 Wrote:Im implementing json control im my touchscreen remote program I am building and I have no means of returning json at this moment am only implementing sending commands using tcp port 9090. Is there any where in my install that I may find a list of current commands for the build I am using(oct 20). Or is there a post I can put into IE that will return the list?
Or is there any return from tcp/udp transfers on a certain port I can look for or is the returns http only at this time?

I have been so frustrated trying to implement this and then I realised I had 5 diff builds on my various pcs and mediaplayers. All up to date at this point Smile

You can use a simple telnet program to open a TCP connection on a computer and then execute JSONRPC.Introspect. Or you can use the "Rest Client" extension for Google Chrome to send the jsonrpc request over HTTP to get the result in an easier readable format.

I'm planning to update the jsonrpc wiki article later today so you may be able to take a look there.


- jimk72 - 2011-10-22

Ok thanks. great job so far!! Once I got them all up to date everything started working. The one version was from over 2 years ago. After messing with PuTTy and seeing all the things going back and forth I think I am going to try and implement full control and access to Xbmc. I was shocked to see that it even notified me of when the screensaver started. Great work!! The hard part is Im using Delphi and an old version and Im not a student anymore so no discount and the new versions are insane Sad Just have to do more research and learn a few more things about networking.


Deleted files - Mizaki - 2011-10-22

Player.Open returns "ok" even if a file fails to play. I not sure if and where this should have failed.

I moved an album. It's still in my library (not cleaned yet). I can add it to a playlist (same as in the GUI) but if I try to play it in the GUI I get an error.

So, should I be able to add it to the playlist and should player.open return an okay result?


- carmenm - 2011-10-23

Hi,
I have updated my xbmc to the latest build and now a request like that
{"method":"Player.GetActivePlayers","id":"1","jsonrpc":"2.0","params":[]}
give me back a json object with an empty result.

What i am doing wrong?

Thanks


- Montellese - 2011-10-23

Mizaki Wrote:Player.Open returns "ok" even if a file fails to play. I not sure if and where this should have failed.
"OK" is not an XBMC-specific answer but a JSON-RPC answer from the specification. It means that there was no error in your request and that all parameters etc were valid. It doesn't say anything about whether Player.Open has actually started playing an item or not. Currently there is no way for me to return more information in the JSON-RPC response because starting the playback happens asynchronously to the Player.Open call so after executing the method in JSON-RPC I don't know either whether it actually worked or not.

Mizaki Wrote:I moved an album. It's still in my library (not cleaned yet). I can add it to a playlist (same as in the GUI) but if I try to play it in the GUI I get an error.

So, should I be able to add it to the playlist and should player.open return an okay result?
If you haven't cleaned your database yet XBMC doesn't know whether the album with that albumid actually still exists or not. As long as it is part of the database it is considered as valid and existing. Therefore you can add it to a playlist without any problem (as XBMC doesn't do any existance check) but obviously when you try to play it, it will fail because the player can't find the file and therefore can't read and play it.
So IMO that behaviour is correct to me. That's what cleaning the database is for (until XBMC has a source-watcher which auto-detects file deletion/creation/movements).

carmenm Wrote:Hi,
I have updated my xbmc to the latest build and now a request like that
{"method":"Player.GetActivePlayers","id":"1","jsonrpc":"2.0","params":[]}
give me back a json object with an empty result.

What i am doing wrong?
Do you have a player running? Since the Player rewrite I made a few weeks ago Player.GetActivePlayers returns an array of active players and as long as you don't have any active players that array is obviously empty. Please check the method definition in JSONRPC.Introspect to see how it works now.


- Mizaki - 2011-10-23

Thanks. That all makes perfect sense.


- carmenm - 2011-10-23

Montellese Wrote:Do you have a player running? Since the Player rewrite I made a few weeks ago Player.GetActivePlayers returns an array of active players and as long as you don't have any active players that array is obviously empty. Please check the method definition in JSONRPC.Introspect to see how it works now.

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 xmbc answered correctly).
Moreover, i was watching a movie!

I ll post a complete response example this afternoon.

Thanks for your quick answer.