Kodi Community Forum
listitem setinfo date bug - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: listitem setinfo date bug (/showthread.php?tid=357061)



listitem setinfo date bug - zachmorris - 2020-09-12

Hello, I believe I've found a bug, but wondering if this is expected or not, or if there's a workaround.

I pass dates to Kodi listitems via a dictionary:
python:

li.setInfo(media_type,{'date':parsed_date})

The docs state the format needs to be:
date string (d.m.Y / 01.01.2009) - file date

So I have a function that parses an unformatted date I get from outside sources:
python:

try:
return date_parser.parse(date_in).strftime('%d.%m.%Y')
except:
return None

The problem is, when I recieve garbage from my outside source, (for example date_in = 'blah'), then when I pass None to setinfo date the logs are spammed with:
python:

ERROR <general>: NEWADDON Invalid Date Format ""

Is there a value I can pass to setinfo that will both be valid and be "None"? Since I can't control the data I receive, I need to have a fallback value to be able to pass.

Thanks in advance for any suggestions.


RE: listitem setinfo date bug - ronie - 2020-09-13

can't you simply omit the date when it's invalid?
python:

info = {}
info['title'] = title
info['genre'] = genre
if parsed_date:
    info['date'] = parsed_date

li.setInfo(media_type,info)



RE: listitem setinfo date bug - zachmorris - 2020-09-13

(2020-09-13, 00:13)ronie Wrote: can't you simply omit the date when it's invalid?
python:

info = {}
info['title'] = title
info['genre'] = genre
if parsed_date:
    info['date'] = parsed_date

li.setInfo(media_type,info)

Thanks. Yes I could do that, but from a coding standpoint, I pass all info tags in one dict:
python:

li.setInfo(media_type,dict_in.get('info'))
Where dict_in contains a bunch of info tags (roughly 20). This appears to be the only one that complains when it's passed None.


RE: listitem setinfo date bug - ronie - 2020-09-13

looking at the source-code: https://github.com/xbmc/xbmc/blob/master/xbmc/interfaces/legacy/ListItem.cpp#L439-L450
kodi will only log the error if the date string isn't 10 characters long.
so try to set it to 10 spaces:
python:
li.setInfo('video', {'date': '          '})