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)



- carmenm - 2011-06-24

Montellese Wrote:I just made a few commits to fix a few bugs and add new functionality. There are two new methods Export and Clean in AudioLibrary and VideoLibrary and ScanForContent has been renamed to Scan. Furthermore the "thumbnail" field is now always returned when it is requested even if it's empty.

Wow great news!. Thanks a lot for that one!

I have a question about "Now Playing" in XBMC, what is the equivalent in JSON. I mean is it :
if (VideoPlayerAvailable) return VideoPlaylist.GetItems
else if (AudioPlayerAvailable) return AudioPlaylist.GetItems

Did i get it right?


- Montellese - 2011-06-24

What exactly does
pfeifer Wrote:Don't work.
mean? Do you get an error in the jsonrpc response or does the video not start playing in XBMC or something else?


- Montellese - 2011-06-24

carmenm Wrote:Wow great news!. Thanks a lot for that one!

I have a question about "Now Playing" in XBMC, what is the equivalent in JSON. I mean is it :
if (VideoPlayerAvailable) return VideoPlaylist.GetItems
else if (AudioPlayerAvailable) return AudioPlaylist.GetItems

Did i get it right?

Yeah you basically call Player.GetActivePlayers. From the response you get you can determine whether the video or the audio player is active. Based on that you call VideoPlaylist.GetItems or AudioPlaylist.GetItems and use the "current" attribute you get in the result to determine the index of the currently playing item in the list of items also returned by GetItems().


- pfeifer - 2011-06-24

Montellese Wrote:What exactly does

mean? Do you get an error in the jsonrpc response or does the video not start playing in XBMC or something else?

Of course, don't start in XBMC and this is the response:

Code:
{
    "error": {
        "code": -32700,
        "message": "Parse error."
    },
    "id": null,
    "jsonrpc": "2.0"
}

if I try this one

Code:
{
    \"jsonrpc\": \"2.0\",
    \"method\": \"XBMC.Play\",
    \"params\": {
        \"file\": \"smb: //192.168.1.12/hdlacie/Varie/myfim.avi\",
        \"type\": \"video\"
    },
    \"id\": 1
}

this is the answer

Code:
{
    "error": {
        "code": -32602,
        "data": {
            "message": "Too many parameters",
            "method": "XBMC.Play",
            "stack": {
                "name": "file",
                "type": "string"
            }
        },
        "message": "Invalid params."
    },
    "id": 1,
    "jsonrpc": "2.0"
}



- Montellese - 2011-06-24

OK the problem with your first request are the backslashes in the path. Python needs you to escape a backslash so you use "\\" to get "\" in the end. But jsonrpc also expects a backslash to be escaped so in your case you probably need to do "\\\\" to get "\\".

Furthermore in the latest nightlies the XBMC.Play method only takes a "file" parameter and nothing else which is why your second request fails and tells you "Too many parameters".


- pfeifer - 2011-06-25

Ok, I changed to Putty for check it

this command work fine (local file and smb file)

Now I have to manage python conversion of file name stored in XBMC and my script.

Thanks a lot

Pfeifer


- Nick8888 - 2011-06-25

topfs2 Wrote:Well it has been discussed and it all comes down to that reading the backbuffer at a significant speed takes up way to much resource so you'd get a significant impact on the htpc. Also transfering the screenshots / movie thing will take alot of bandwith and adding compression to that would probably not be beneficial since it will take even more cpu cycles on both client and htpc, although it would be needed to be investigated.

regarding 3 and 4, we don't have that code in place in xbmc by normal so no way of detecting it. when XBMC supports dirty regions and event based rendering this would be revisable.

WIth that being said rendering the video @ 64x64 might be added since ambilight daemons could use that data.

I do find the idea interesting but unfortuanatly I doubt we can do it better than vnc and such already do, essentially have the same problems. Although since the data fetching will be so easy it will be a snap for other clients to display the data instead.

Is it still unlikely we will see a screenshot method anytime soon?


- pilluli - 2011-06-26

Hi guys,

I was in the process of updating a python script to use the JSON-api instead of the deprecated http-api but I run into some problems/difficulties. I've got a couple of questions:

1. Is it possible to access the list of video bookmarks form the DB and the info (episode or movie) associated with it? If not, is there a plan to add this query?

2. Could someone point me at a guide or some source code of python scripts using the JSON api? I seem to be struggling to find info and examples of this...

best regards and thanks for your work on this API!!


- giftie - 2011-06-27

pilluli Wrote:2. Could someone point me at a guide or some source code of python scripts using the JSON api? I seem to be struggling to find info and examples of this...

I can tell you of two... cdART Manager and Cinema Experience..


cdART Manager - Source

Cinema Experience(dev) - Source

They both have a file called 'json_utils.py' which contain some code accessing the Database for info.

Any questions on how and why feel free to PM.


- carmenm - 2011-06-27

@Montellese: i saw that you added the thumbnails for cast. Thank you! Will try it as soon as possible.


- Montellese - 2011-06-27

carmenm Wrote:@Montellese: i saw that you added the thumbnails for cast. Thank you! Will try it as soon as possible.

You're welcome. You will not get a thumbnail though if there is none cached by xbmc.


- carmenm - 2011-06-27

Montellese Wrote:You're welcome. You will not get a thumbnail though if there is none cached by xbmc.

Of course Laugh


- pilluli - 2011-06-27

giftie Wrote:I can tell you of two... cdART Manager and Cinema Experience..

cdART Manager - Source

Cinema Experience(dev) - Source

They both have a file called 'json_utils.py' which contain some code accessing the Database for info.

Any questions on how and why feel free to PM.

Thank you giftie, that is exactly what I was looking for. Smile

Does anyone know if it is possible to access the list of video bookmarks from the DB and the info (episode or movie) associated with it??

Regards,


Sorting - thedroid - 2011-06-29

It appears that sorting by title does not work (using xbmc 11.0-git20110629.a401db7)

Code:
{"id":7,"jsonrpc":"2.0","method":"VideoLibrary.GetMovies","params":{"fields":["title"],"limits":{"start":0,"end":3} ,"sort":{"method":"title","order":"ascending","ignorearticle":false}}}

incorrectly produces

Code:
{"id":7,"jsonrpc":"2.0","result":
    {"limits":{"end":3,"start":0,"total":1207},"movies":
        [    {"label":"The Day of the Jackal","movieid":3,"title":"The Day of the Jackal"},
            {"label":"3:10 to Yuma","movieid":5,"title":"3:10 to Yuma"},
            {"label":"8½","movieid":6,"title":"8½"},
        ]
    }
}


whereas

Code:
{"id":7,"jsonrpc":"2.0","method":"VideoLibrary.GetMovies","params":{"fields":["title"],"limits":{"start":0,"end":3} ,"sort":{"method":"label","order":"ascending","ignorearticle":false}}}

correctly produces

Code:
{"id":7,"jsonrpc":"2.0","result":
    {"limits":{"end":3,"start":0,"total":1207},"movies":
        [    {"label":"(500) Days of Summer","movieid":17,"title":"(500) Days of Summer"},
            {"label":"3:10 to Yuma","movieid":5,"title":"3:10 to Yuma"},
            {"label":"5 Days of August","movieid":1326,"title":"5 Days of August"}
        ]
    }
}

Is this a known issue?


- Montellese - 2011-06-29

thedroid Wrote:It appears that sorting by title does not work (using xbmc 11.0-git20110629.a401db7)

That is because you have to use the "videotitle" sort method and not the "title" sort method for videos. I know it's not very intuitive but that's the way it currently is.