Kodi Community Forum
Accessing database from script - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Accessing database from script (/showthread.php?tid=227070)



Accessing database from script - Tricky - 2015-05-15

Can anybody give me an example of how to get for instance a list of all the TV shows in a python script or a simple addon that I can look at to learn?


RE: Accessing database from script - curti - 2015-05-15

You will want to look at the http://kodi.wiki/view/JSON-RPC_API to get a list of items in the library.


Accessing database from script - Tricky - 2015-05-16

I'm probably a complete idiot but I'm not really understanding it. Executejsonrpc is a method of xbmc, but how do I use it?


RE: Accessing database from script - curti - 2015-05-16

(2015-05-16, 01:04)Tricky Wrote: I'm probably a complete idiot but I'm not really understanding it. Executejsonrpc is a method of xbmc, but how do I use it?

The sample below is from a previous post of mine to get a list of watched episodes. More examples are available at: http://kodi.wiki/view/JSON-RPC_API/Examples

Code:
import json
import xbmc

request = {"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "filter": {"field": "playcount", "operator": "greaterthan", "value": "0"}, "limits": { "start" : 0 }, "properties": ["playcount"], "sort": { "order": "ascending", "method": "label" } }, "id": "libTvShows"}
results = json.loads(xbmc.executeJSONRPC(json.dumps(request)))



RE: Accessing database from script - Tricky - 2015-05-16

(2015-05-16, 01:34)curti Wrote:
(2015-05-16, 01:04)Tricky Wrote: I'm probably a complete idiot but I'm not really understanding it. Executejsonrpc is a method of xbmc, but how do I use it?

The sample below is from a previous post of mine to get a list of watched episodes. More examples are available at: http://kodi.wiki/view/JSON-RPC_API/Examples

Code:
import json
import xbmc

request = {"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "filter": {"field": "playcount", "operator": "greaterthan", "value": "0"}, "limits": { "start" : 0 }, "properties": ["playcount"], "sort": { "order": "ascending", "method": "label" } }, "id": "libTvShows"}
results = json.loads(xbmc.executeJSONRPC(json.dumps(request)))


Thank you very much for the help, worked like a charm!!


Accessing database from script - Tricky - 2015-05-17

What is the id:libTvShows for actually?