From d56e47f4137a1f2ff9eee132c6d5f889bdc31f11 Mon Sep 17 00:00:00 2001 From: rysson Date: Sat, 21 Jan 2023 14:23:52 +0100 Subject: [PATCH] Fix ListItem HH:SS duration. Some addons sets a duration as [HH:]MM:SS but the Kodi requests an integer in `ListItem.setInfo("duration": seconds)`. The fix converts [HH:]MM:SS format to the seconds number. --- plugin.program.autowidget/resources/lib/common/directory.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin.program.autowidget/resources/lib/common/directory.py b/plugin.program.autowidget/resources/lib/common/directory.py index 5063f84e..2c24b318 100644 --- a/plugin.program.autowidget/resources/lib/common/directory.py +++ b/plugin.program.autowidget/resources/lib/common/directory.py @@ -186,6 +186,10 @@ def add_menu_item( item.setMimeType(value) elif key == "artist": new_value = [value] + elif key == "duration" and isinstance(value, str) and ":" in value: + # Fix duration from [HH:]MM:SS to the number of seconds (integer) + factors = (1, 60, 3600) + new_value = sum(int(v) * f for v, f in zip(value.split(':')[::-1], factors)) else: new_value = ( value