Can I get the DBID from a Python ListItem?
#1
Can I get the DBID from a Python xbmcgui.ListItem?

The new context menu item add-ons in Isengard pass along the selected item as sys.listitem, and I need to get the DBID from that, what skins access as 'ListItem.DBID'. I've looked through the docs and wiki and haven't found what I need, but Kodi has a lot of hidden nooks and crannies and I'm hoping I just missed it.

xbmc.getInfoLabel('ListItem.DBID') works sometimes, but not reliably: seemingly always accurate for movies, usually accurate for TV shows, but occasionally picks a random show (which is the killer for me), and for episodes it always seems to pick the first item in the list ('..'/1st episode/etc). I'm unsure about music videos. The docs do say to use sys.listitem, so it's not really a bug, but it sure is unfortunate because that's exactly what I need.
Reply
#2
(2015-07-26, 23:09)rmrector Wrote: Can I get the DBID from a Python xbmcgui.ListItem?

The new context menu item add-ons in Isengard pass along the selected item as sys.listitem, and I need to get the DBID from that, what skins access as 'ListItem.DBID'. I've looked through the docs and wiki and haven't found what I need, but Kodi has a lot of hidden nooks and crannies and I'm hoping I just missed it.

xbmc.getInfoLabel('ListItem.DBID') works sometimes, but not reliably: seemingly always accurate for movies, usually accurate for TV shows, but occasionally picks a random show (which is the killer for me), and for episodes it always seems to pick the first item in the list ('..'/1st episode/etc). I'm unsure about music videos. The docs do say to use sys.listitem, so it's not really a bug, but it sure is unfortunate because that's exactly what I need.

It would be helpful if you posted your code, getinfolabel should return the proper id information.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
Doh! I forgot to mention that this only happens when my context item is under 'Manage...'.

Quick test add-on is context.manage.unfortunate. If the infolabel and sys.listitem labels don't match, it'll pop up a notification.

Further testing of the infolabel ListItem is just even more frustrating, and to me it feels like this is exactly the reason sys.listitem is provided in the first place. It seems like a matter of timing, and with the way skinning works, the fact xbmc.getInfoLabel usually runs at the right time doesn't mean it's guaranteed to.

On my Windows desktop with a fresh install and fresh AppData (.kodi), the occasional incorrect TV show is sometimes the first show visible on screen when I'm viewing them as a list, or sometimes it picks a random other show from the full list. It does seem to be accurate on an OpenElec HTPC, Surface Pro 2 using a keyboard, and Android using touch, though.

Episodes are often thrown off by the setting "Select first unwatched TV show season/episode", on the desktop the infolabel is generally always the first unwatched item, the openelec usually picked the first visible item in the list for long lists (items extend offscreen), and randomly* for short lists (all items fit on the screen at the same time), on the surface pro 2 it picked randomly* for a short list, and for a long list it was accurate. Android touch always seemed to be accurate. With the setting set to 'Never' Openelec usually picked the first item visible on screen for long lists, and randomly* for short lists, it behaves the same as 'Always'. With it set to 'Never', the desktop, SP2, and Android were accurate.

Movies always seemed to be accurate. Music videos unknown.

* semi-random, it picks either the first unwatched item or one specific other episode for each specific episode I select; for instance, selecting episode 10 usually picks episode 3, but sometimes episode 1. selecting episode 8 usually picked episode 6, but sometimes 1.
Reply
#4
Bump because the edit didn't do it.
Reply
#5
I've found that when under the 'Manage...' menu the listitem.getfilename() returns a 'videodb://' URL that I can pull the DBID from if I need to.
The below code pulls the ID out of the filename if it encounters a mismatch.

Code:
infolabel = xbmc.getInfoLabel('ListItem.Label')
truelabel = sys.listitem.getLabel()
if infolabel == truelabel:
    dbid = xbmc.getInfoLabel('ListItem.DBID')
else:
    dbid = sys.listitem.getfilename().split('?')[0].rstrip('/').split('/')[-1]
Reply

Logout Mark Read Team Forum Stats Members Help
Can I get the DBID from a Python ListItem?0