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)



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Samtronic - 2014-03-06

Hi !

Is it possible in json to list movie based on cast name.

Thanks
Steven


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2014-03-06

(2014-03-06, 21:12)Samtronic Wrote: Hi !

Is it possible in json to list movie based on cast name.

Thanks
Steven

You can try to use a filter using the "actor" filter.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Samtronic - 2014-03-07

This works perfectly with the actor filter

Thanks


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jez500 - 2014-03-08

(2014-02-16, 17:13)Montellese Wrote:
(2014-02-13, 14:58)jez500 Wrote: 3. Persistent storage - I am pretty sure this is a feature request however I might have just missed it too. I would love a way to save/retrieve some data on the host via the api. something like storage System.setVariable {key: value} and System.getVariable {key}. I have heaps of cool ideas if such a thing existed (eg. web ui settings, who played that song and many more ). Any suggestions?
I don't understand what exactly you are after.

Hi Montellese,
Thanks for the responses, all good to know.

With the "persistent storage" it's probably easiest to explain it with an example...
Say in my web interface I want the user to be able to select a color scheme, at the moment I can only save this setting in local browser storage, meaning if they switch browsers then that setting is lost. I would like to be able to store this setting server side (in xbmc) so if the user uses another browser, I can pull the setting from xbmc and apply it accordingly.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2014-03-08

(2014-03-08, 06:09)jez500 Wrote: Hi Montellese,
Thanks for the responses, all good to know.

With the "persistent storage" it's probably easiest to explain it with an example...
Say in my web interface I want the user to be able to select a color scheme, at the moment I can only save this setting in local browser storage, meaning if they switch browsers then that setting is lost. I would like to be able to store this setting server side (in xbmc) so if the user uses another browser, I can pull the setting from xbmc and apply it accordingly.

Over a year ago I wrote some python modules and other code to allow webinterfaces to use python including session and cookie handling.
Unfortunately by the time I was done the whole python interface was changed and I never got around to adjust my code because the new code is completely different. But I still want to make that happen one day.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jez500 - 2014-03-08

(2014-03-08, 09:15)Montellese Wrote:
(2014-03-08, 06:09)jez500 Wrote: Hi Montellese,
Thanks for the responses, all good to know.

With the "persistent storage" it's probably easiest to explain it with an example...
Say in my web interface I want the user to be able to select a color scheme, at the moment I can only save this setting in local browser storage, meaning if they switch browsers then that setting is lost. I would like to be able to store this setting server side (in xbmc) so if the user uses another browser, I can pull the setting from xbmc and apply it accordingly.

Over a year ago I wrote some python modules and other code to allow webinterfaces to use python including session and cookie handling.
Unfortunately by the time I was done the whole python interface was changed and I never got around to adjust my code because the new code is completely different. But I still want to make that happen one day.

Ahh ok, yeah I was thinking it might have to be the job of another addon. Ok cool, I might investigate a 'companion' module in the future if you don't beat me to it.
Thanks!


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2014-03-10

Artistid is not returned when using Files.GetDirectory function on "Songs" smart playlist :

Code:
_json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "music", "properties": ["artistid","albumid","dateadded"]}, "id": 1}' %(PLAYLIST))

Informations returned :

Code:
{u'filetype': u'file', u'label': u'Total Breakdown', u'albumid': 3, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2008 - Out of it/07_-_Brad_Sucks_-_Total_Breakdown.mp3', u'type': u'song', u'id': 1233},
{u'filetype': u'file', u'label': u'Never Get Out', u'albumid': 2, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2003 - I dont t know what I m doing/08_-_Brad_Sucks_-_Never_Get_Out.mp3', u'type': u'song', u'id': 1222},
{u'filetype': u'file', u'label': u'Borderline', u'albumid': 2, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2003 - I dont t know what I m doing/06_-_Brad_Sucks_-_Borderline.mp3', u'type': u'song', u'id': 1220},

Does Wiki is not up to date :

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#List.Fields.Files

Tested with Frodo 12.3 and 13.0-BETA2 Git:20140310-64a9cb9


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - ben- - 2014-03-12

(2012-07-02, 11:56)Millencolin007 Wrote: Setting the movie as unwatched does not work. Tried the following two requests
Code:
curl  -H "Content-Type: application/json"  -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.SetMovieDetails\", \"params\" : { \"movieid\" : 1, \"playcount\" : 0,  \"lastplayed\" :  \"\" }, \"id\" : 1 }" http://127.0.0.1:8080/jsonrpc | python -mjson.tool

I just tried this in Gotham Beta-1. Setting lastplayed to "" doesn't seem to be working for me. The API call returns OK, but when querying the details immediately after the call, the old lastplayed date string remains. Is there a special way to assign a string value to empty now?

Clicking the marked as unwatched button in the UI returns the value to "" as expected.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2014-03-12

(2014-03-10, 13:18)mikebzh44 Wrote: Artistid is not returned when using Files.GetDirectory function on "Songs" smart playlist :

Code:
_json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "music", "properties": ["artistid","albumid","dateadded"]}, "id": 1}' %(PLAYLIST))

Informations returned :

Code:
{u'filetype': u'file', u'label': u'Total Breakdown', u'albumid': 3, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2008 - Out of it/07_-_Brad_Sucks_-_Total_Breakdown.mp3', u'type': u'song', u'id': 1233},
{u'filetype': u'file', u'label': u'Never Get Out', u'albumid': 2, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2003 - I dont t know what I m doing/08_-_Brad_Sucks_-_Never_Get_Out.mp3', u'type': u'song', u'id': 1222},
{u'filetype': u'file', u'label': u'Borderline', u'albumid': 2, u'file': u'smb://READYNAS/media/Music/Brad Sucks/2003 - I dont t know what I m doing/06_-_Brad_Sucks_-_Borderline.mp3', u'type': u'song', u'id': 1220},

Does Wiki is not up to date :

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#Files.GetDirectory

http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#List.Fields.Files

Tested with Frodo 12.3 and 13.0-BETA2 Git:20140310-64a9cb9
I'll look into it when I have some time but a lot has changed in the music database and I'm not familiar with it anymore at all.

And yes the documentation on the wiki is not up-to-date,

(2014-03-12, 02:49)ben- Wrote:
(2012-07-02, 11:56)Millencolin007 Wrote: Setting the movie as unwatched does not work. Tried the following two requests
Code:
curl  -H "Content-Type: application/json"  -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.SetMovieDetails\", \"params\" : { \"movieid\" : 1, \"playcount\" : 0,  \"lastplayed\" :  \"\" }, \"id\" : 1 }" http://127.0.0.1:8080/jsonrpc | python -mjson.tool

I just tried this in Gotham Beta-1. Setting lastplayed to "" doesn't seem to be working for me. The API call returns OK, but when querying the details immediately after the call, the old lastplayed date string remains. Is there a special way to assign a string value to empty now?

Clicking the marked as unwatched button in the UI returns the value to "" as expected.

Thanks for the report. Looks like all properties/fields that expect a date/time will fail with an empty value. I'll try to fix it ASAP.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - ben- - 2014-03-12

(2014-03-12, 08:57)Montellese Wrote: Thanks for the report. Looks like all properties/fields that expect a date/time will fail with an empty value. I'll try to fix it ASAP.

Great, thanks! Just to clarify, I would use "" (the empty string) to clear the field? This seems correct to me since the null value is used to ignore the attribute altogether when setting details.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2014-03-12

(2014-03-12, 18:21)ben- Wrote: Great, thanks! Just to clarify, I would use "" (the empty string) to clear the field? This seems correct to me since the null value is used to ignore the attribute altogether when setting details.

Yup that's correct. But there is some logic in the database that doesn't let you reset lastplayed when the playcount is greater than 0.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - ben- - 2014-03-12

(2014-03-12, 19:06)Montellese Wrote:
(2014-03-12, 18:21)ben- Wrote: Great, thanks! Just to clarify, I would use "" (the empty string) to clear the field? This seems correct to me since the null value is used to ignore the attribute altogether when setting details.

Yup that's correct. But there is some logic in the database that doesn't let you reset lastplayed when the playcount is greater than 0.

That constraint is logical since there could never be a case where play count is non-zero with no last played time. I'm implementing "mark as watched" and "mark as unwatched" via the JSON API so I will always be modifying both attributes at the same time. Thanks again!


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2014-03-13

(2014-03-12, 19:15)ben- Wrote:
(2014-03-12, 19:06)Montellese Wrote:
(2014-03-12, 18:21)ben- Wrote: Great, thanks! Just to clarify, I would use "" (the empty string) to clear the field? This seems correct to me since the null value is used to ignore the attribute altogether when setting details.

Yup that's correct. But there is some logic in the database that doesn't let you reset lastplayed when the playcount is greater than 0.

That constraint is logical since there could never be a case where play count is non-zero with no last played time. I'm implementing "mark as watched" and "mark as unwatched" via the JSON API so I will always be modifying both attributes at the same time. Thanks again!

PR4405 should take care of the problem.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2014-03-15

There was some discussion about this previously, but is it really the case now that you can only call Files.GetDirectory on paths within your sources (as defined in sources.xml)?

The thing is, I have a MySQL setup which is using a Raspberry Pi as the "scraper" (it's on 24x7 etc.) which has a fully defined sources.xml, and all my other clients (which don't do any scraping) haven't been setup with a sources.xml at all. It's working great, apart from JSON which doesn't allow any calls to GetDirectory on the clients without a sources.xml.

Is there no other way to validate/verify the path being requested other than against sources.xml? Wouldn't it be better to validate the requested path against whatever sources/paths are in the database, which would mean sources.xml isn't required?

Granted it's not a big deal to duplicate the sources.xml on every client just for GetDirectory to work, although I had hoped to eliminate sources.xml from every non-scraping client just to prevent them from performing any unintended scraping. Smile


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2014-03-15

Well in the end it's a problem to duplicate since users often add then by hand with a different case Sad

Leading to no access via VFS for example see https://github.com/xbmc/xbmc/pull/4391 Smile

And furthermore if they scrape one movie on one different case host then others do not have access to and there's no way to recover from this appart drop of source and all database then full rescrape after having corrected all Smile