Programmatically Selecting a ListItem in a Plugin
#1
Kodi has the nice setting to select the first unwatched episode of a series. That's great, but it doesn't work in addons, and since addons are not necessarily providing a list that is relevant to that setting, it's fine.
Not working code that I think should
The plugin_dir object adds directory items and calls endofdirectory. I'm confident that code works well, but posting all of it would clutter up the forums.
My issue is that ListItem.select(self, selected: bool) -> None seems to do absolutely nothing, let alone what it's supposed to.
Working code that isn't reliable or good practice
This code works, but if it's called without enough time for Kodi to do proper endOfDirectory() stuff, then it does nothing, as the directory doesn't exist yet. It's generally bad practice to wait an arbitrary amount of time and assume it's enough, so what are my options?
Developer for Shoko and Nakamori. Long time user of Kodi, before it was even called Kodi. My XBOX died long ago, but Windows is still just as broken and necessary. I obviously watch anime, given my first comment. Video games, manga, music, you name it.
Reply
#2
(2019-03-17, 06:51)da3dsoul Wrote: Kodi has the nice setting to select the first unwatched episode of a series. That's great, but it doesn't work in addons, and since addons are not necessarily providing a list that is relevant to that setting, it's fine.
Not working code that I think should
The plugin_dir object adds directory items and calls endofdirectory. I'm confident that code works well, but posting all of it would clutter up the forums.
My issue is that ListItem.select(self, selected: bool) -> None seems to do absolutely nothing, let alone what it's supposed to.
Working code that isn't reliable or good practice
This code works, but if it's called without enough time for Kodi to do proper endOfDirectory() stuff, then it does nothing, as the directory doesn't exist yet. It's generally bad practice to wait an arbitrary amount of time and assume it's enough, so what are my options?

I am having a very similar problem to this. I am using the following code to create my directory:


xbmcplugin.setContent(PLUGIN_HANDLE, 'tvshows')
xbmcplugin.setPluginCategory(PLUGIN_HANDLE, 'My Directory')
xbmcplugin.addDirectoryItems(PLUGIN_HANDLE, menu_items_xbmc, len(menu_items_xbmc))
xbmcplugin.endOfDirectory(PLUGIN_HANDLE)

`menu_items_xbmc` is an array of tuples (url, list item, True/False). On the list item I want to be selected I call `.select(True)` When I run my plugin  I see the list item has a different color treatment but the ".." is always the active entry if that makes sense. I would like to make the active entry one I called `.select(True)` on so the user could just press enter without having to scroll.
Kodi 18.4 | Ubuntu 18.04.3 | Intel i7-8700K | ASRock Z370 Gaming-ITX/ac | Ballistix Sport LT 2x16384MB (DDR4-2666) | Samsung 970 PRO 1TB |LG WH16NS60 | Cooler Master Elite 130 | Yamaha RX-A780Samsung Q70R
Reply
#3
You can calculate number of "Down" events and follow it with "Select" event:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Input.Down","id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Input.Select","id":1}')
https://github.com/Virusmater/plugin.aud...lt.py#L152
This is not an ideal, but an only possible way of doing it for me.
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Programmatically Selecting a ListItem in a Plugin00
This forum uses Lukasz Tkacz MyBB addons.