有没有办法在您的插件中访问来自第三方 kodi/xbmc 插件的 python 代码?
Is there a way to access python code from third party kodi/xbmc plugins in your plugin?
我有 python 的经验,但我才刚刚开始学习如何为 Kodi 开发插件。理解文档有点困难。
是否可以从另一个插件或脚本导入或以其他方式访问 python 代码?
例如,如果我的插件是:script.hello.world
,我想使用 plugin.video.someplugin
中的 some_method
。
addon.xml 导入我希望访问的插件:
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="plugin.video.plexbmc" version="3.4.5" optional="true"/>
</requires>
我很确定这行不通,我是对的:
from plugin.video.someplugin.default import some_method
文档中唯一看起来可行的是:
spi = xbmcaddon.Addon ('plugin.video.someplugin')
我可以访问 xbmc 的内置 spi 方法,但无法访问实际的 python 对象。
知道了!只需将所需目录添加到系统的 python 路径:
spi = xbmcaddon.Addon ('plugin.video.someplugin')
path = spi.getAddonInfo('path')
sys.path.append (xbmc.translatePath( os.path.join( path) ))
from default import some_method
some_method()
我有 python 的经验,但我才刚刚开始学习如何为 Kodi 开发插件。理解文档有点困难。
是否可以从另一个插件或脚本导入或以其他方式访问 python 代码?
例如,如果我的插件是:script.hello.world
,我想使用 plugin.video.someplugin
中的 some_method
。
addon.xml 导入我希望访问的插件:
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="plugin.video.plexbmc" version="3.4.5" optional="true"/>
</requires>
我很确定这行不通,我是对的:
from plugin.video.someplugin.default import some_method
文档中唯一看起来可行的是:
spi = xbmcaddon.Addon ('plugin.video.someplugin')
我可以访问 xbmc 的内置 spi 方法,但无法访问实际的 python 对象。
知道了!只需将所需目录添加到系统的 python 路径:
spi = xbmcaddon.Addon ('plugin.video.someplugin')
path = spi.getAddonInfo('path')
sys.path.append (xbmc.translatePath( os.path.join( path) ))
from default import some_method
some_method()