Changes to the python API for Kodi Leia
#1
Below you'll find an up-to-date list of all changes made to the python API since the release of Kodi Krypton.


previous threads:
Please keep this thread clean. It should be an easy overview for python coders who are updating their addon for Kodi Krypton.
For discussions / feature requests / bugreports, please find (or create) the appropriate thread in the addon development forum.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#2
2017-01-04 DBID for music items

addons can now set & get the dbid for music items

Code:
listitem.setInfo('music', {'mediatype':'song', 'dbid':12345})

dbid = listitem.getMusicInfoTag().getDbId()



pull request: https://github.com/xbmc/xbmc/pull/10858
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
2017-01-04 WindowXML setContent

addons using WindowXML that are creating a media list using the built-in container,
can now set the content of the container:

Code:
self.setContent('movies')



pull request: https://github.com/xbmc/xbmc/pull/11258
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
2017-01-05 mediatype for music items

addons can now get the mediatype for music items

Code:
mediatype = listitem.getMusicInfoTag().getMediaType()



pull request: https://github.com/xbmc/xbmc/pull/11110
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
2017-01-05 int/float support for slider controls

addons can now define a float or int range (instead if just a fixed 0-100%) range for slider controls

Code:
self.slider.setFloat(15.0, 10.0, 1.0, 20.0)
self.slider.getFloat()

self.slider.setInt(450, 200, 10, 900)
self.slider.getInt()

the params are: current value, min value, step size, max value


pull request: https://github.com/xbmc/xbmc/pull/11230
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#6
(2017-01-04, 22:55)ronie Wrote: 2017-01-04 WindowsXML setContent
addons using WindowsXML that are creating a media list using the built-in container,
can now set the content of the container:
Code:
self.setContent('movies')
pull request: https://github.com/xbmc/xbmc/pull/11258

I'm just curious,

setContent() lets the skin know how to list the directory items, what view types will be available and which infolabels to display.

Using windowsXML bypasses the skin system and can use setProperty/getProperty to pass values. Why use setContent() ?
Reply
#7
it's only useful if you use the built-in container of the window, which 99.999999999% of the addons don't use ;-)

pretty much all addons define a container and add listitems to it:
Code:
self.getControl(1234).addItems(listitems)

but you can also add the listitems directly to the window:
Code:
self.addItems(listitems)

if you use that method, you can define multiple view types in the skin xml file of your addon,
and define which views (or other controls) are visible based on the content type.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
2017-03-05 kodi language file changes

not a python related change, but it can potentially affect your addon..

as of PR#11039 the kodi language file no longer uses '%s' / '%i' string formatting.
in case your addon is using any of the affected strings from the kodi language file, please be aware this will no longer work:
Code:
xbmc.getLocalizedString(20464) % foo
xbmc.getLocalizedString(299) % count


pull request: https://github.com/xbmc/xbmc/pull/11039
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#9
2017-03-17 WindowXML isMedia

addons using WindowXML that are creating a media list using the built-in container,
need to set the isMedia bool to True in the window constructor:

Code:
win = xbmcgui.WindowXML('script-globalsearch.xml', xbmcaddon.Addon().getAddonInfo('path').decode('utf-8'), 'default', '1080p', True)

this will allow you to reference the container in the skin xml without specifying the container id.

pull request: https://github.com/xbmc/xbmc/pull/11766
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#10
In the next couple of weeks a PR will go into kodi that keeps python sessions open as long a user navigates inside an addon.
Reason is that this pushes performance significantly because modules are taken from python cache instead reloading / rereading them on every click.

From development side this means: Only the default python script (defined in addon.xml. commonly default.py or addon.py) are re-interpreted on every click.
All imported (sub-) modules will be taken from cache and not reinterpreted.

What does this mean for you python addon dev?

- arguments passed from kodi to addon are only available in default script, if you need them in any of your submodule script you either pass the current arguments from default script into your submodules, or you call sys.argv inside your functions where the code is executed. Storing the value of sys.arg[#] in a global variable at the head of your submodule will not work because the code is only executed once on first module startup, but not on subsequent calls.
- For compatibility reasons sys.argv[0] (base_url) and sys.argv[1] (plugin_handle) stay same when reused. This means that it is possible now to store them in a global variable in submodules.
- if you are debugging / developing a submodule, you may have to first select an other addon and then return to your addon to get a fresh reload. Or switch reusing of python session off (see below)

Reusing of python sessions can be disabled in addon.xml, metadata section:

<extension point="xbmc.addon.metadata">
  <reuselanguageinvoker>false</reuselanguageinvoker>
</extension>

Edit: Pull Request: https://github.com/xbmc/xbmc/pull/13814
Reply
#11
Usage of DialogBusy results in nop now. I removed it becuase it was wrong: https://github.com/xbmc/xbmc/pull/13954

Unfortunately Kodi's GUI lacks a proper MVC (model view controller) architecture. Giving addons the chance to open modal dialogs in an uncontrolled manner is wrong. In this particular case it lead to crashes that I fixed with this change. DialogBusy is a singelto and must only be used once at a given time.

EDIT: as a workaround python scripts can make use of the new DialogBusyNoCancel: https://github.com/xbmc/xbmc/pull/13958
Reply
 
Thread Rating:
  • 1 Vote(s) - 5 Average



Logout Mark Read Team Forum Stats Members Help
Changes to the python API for Kodi Leia51