Kodi Community Forum
Expose a function of my service to JSonRPC - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Service Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=152)
---- Thread: Expose a function of my service to JSonRPC (/showthread.php?tid=251909)



Expose a function of my service to JSonRPC - edup_pt - 2015-12-13

Hello everyone, just joined forum and I am a newbie so hope this makes sense:

I'm building a service add-on in python for kodi and I would like to expose an "api" to JSONRPC in order to have other add ons to call my api functions.

I tried to search online but I can only find how to access to other jsonrpc "api's" as a client (http://kodi.wiki/view/JSON-RPC_API/Examples) but I can't find out how to expose my functions for others to access.

Thanks for your help.


RE: Expose a function of my service to JSonRPC - edup_pt - 2015-12-29

I figured out the solution:

1) I just need to add this line at my service addon.xml file and then it's ready to role:

<extension point="xbmc.python.pluginsource" library="service.py" />


2) to make the call you can use in the skin or eventually using executebuiltin command in your python file:
plugin://script.service.myservice?action=getPlaylist

3) and then receive and threat this call in the service.py where the get arguments are received as arguments (argv) in the service.py:
xbmc.log("[Started Service in API_MODE] > SYS %s : %d : %d" % (sys.argv, len(sys.argv), os.getpid()), level=xbmc.LOGNOTICE)


This forum uses Lukasz Tkacz MyBB addons.