Access pictures in root of addon folder - 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: Access pictures in root of addon folder (/showthread.php?tid=179321) |
Access pictures in root of addon folder - nickthemagicman - 2013-12-01 How does a python add-on get its root directory to access pictures and the like? I have an add on folder: script.test.addon In the root of that folder I want to access .png files from python files but I can't get the root directory. P.S. I'm on a Mac inside of the XBMC .app folder. RE: Access pictures in root of addon folder - nickthemagicman - 2013-12-01 Never mind figured it out! root = os.path.dirname(__file__) I hope this works on windows too but it seems like it would. RE: Access pictures in root of addon folder - foomanshoe - 2013-12-02 You can use the special protocol. Code: PLUGIN_ID = 'plugin.video.sample' See http://wiki.xbmc.org/?title=Special_protocol for more information RE: Access pictures in root of addon folder - doko-desuka - 2018-09-12 This thread is from 2013, pardon the resurrection. ----- It comes up a lot on a Google search. Instead of using the 'special://' protocol to get the path of the root folder of your plugin (it works anyway), there's a more direct way which is using xbmcaddon.Addon().getAddonInfo with 'path' as the property: https://codedocs.xyz/xbmc/xbmc/group__python__xbmcaddon.html#ga65a28456461e069aeeddd13a8a4222fb The folder it returns is already resolved (doesn't use the 'special://' protocol) and does not include the trailing slash, you need to add it, like: Or...
Note that getAddonInfo('profile') returns 'special://profile/addon_data/plugin.video.yourpluginname/' -- that is, it does include the trailing slash and uses 'special://'. To resolve paths with the special protocol you need to use xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('profile')).decode('utf-8'). |