[Release] Duration script - Display movies runtime in hours & minutes
#1
Hi all,

It was annoying me to see movies durations in minutes (for exemple: 157 minutes means nothing for a human being) so I wrote a script to fix this.
I prefer durations in HH:MM or HHhMM format so that's what this script do, it converts movies duration from minutes to hours & minutes to display it on a human-readable way.

Image

2h35 is easier to understand than 155, right ?
Image

I released it here : https://github.com/twolaw/script.duration

(updated in december 2017 thanks to axbmcuser work, available here : https://github.com/axbmcuser/_repo/tree/..._axbmcuser )

Of course, your kodi skin has to be tweaked to trigger the script and to display the value calculated.

---------------------------------------------------
HOW TO TWEAK YOUR SKIN
---------------------------------------------------

Exemple: for the Estuary skin, these 2 xml files need to be modified as follow :

Variables.xml

Add this new variable at the end of the file (before the </include>) :

    <variable name="ItemDuration">
        <value condition="System.HasAddon(script.duration) +
                    [Window.IsVisible(Videos) | Window.IsVisible(Movieinformation)] +
                    !String.IsEmpty(Window(Home).Property(Durations.Hours)) +
                    !String.IsEqual(Window(Home).Property(Durations.Hours),0) +
                    !String.IsEmpty(Window(Home).Property(Durations.DBID)) +
                    String.IsEqual(Window(Home).Property(Durations.DBID),ListItem.DBID)">$INFO[Window(Home).Property(Durations.HoursMinutes)]</value>
        <value>$INFO[ListItem.Duration] min</value>
    </variable>


Includes.xml

Replace <label>$INFO[ListItem.Duration,, $LOCALIZE[31132]]</label> with <label>$VAR[ItemDuration]</label>

--------------------------------------------------------------------------------------------------------------------
This way, your skin can still display a duration even if the script.duration is not installed.
It's my first script, so it must be far from perfection but it fully works on my HTPC. Blush
Tell me what you think of it.
Reply
#2
It works nice,thank you .
Reply
#3
Hi,

Would it be possible to have a look at your variables.xml to see how conditions are handled ? I know i have to use $INFO[window.Property(Duration)] instead of $INFO[ListItem.Duration], but i was wondering if there is a more elegant way to substitute each instance globally hence without altering the base code (don't know if i am crystal clear here ;D ).

Thnaks
Reply
#4
@mkortstiege
imo this should be something that is by default available for skins
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Well, my first try to realy mod a skin and i already put my finger on big a drawback - if it is not possible.
In my case there are 25 instances of it with conditions long as my arm and a lot of ! conditions. If i need to add another condition it means duplicating the existing ones + creating a lot of new sets for the ! condition... meh oO
Reply
#6
Yes you can add it and keep the base code so it can still works even if the script.duration is not installed.

edit 2015-04-24 : Mike_Doc's technique described below on post #11 is very good, i used it on the readme file, no need to manipulate multiple conditions. Thank you Mike !
Reply
#7
Hmm thanks, but you still have to duplicate all the references locally which is a pain ... I though of a more global way to do it, but it seems to be impossible Sad

Like a "if controle type has Listitem.Duration AND System.HasAddon(script.duration) then replace Listitem.Duration by window.Property(Duration)"
Reply
#8
(2015-04-07, 16:02)Martijn Wrote: @mkortstiege
imo this should be something that is by default available for skins

+1

Like Player.Duration(Format) : http://kodi.wiki/view/InfoLabels#Player_labels

And skinners or Kodi in language settings should just have a centralized setting to choose between duration in minutes and duration with format hh:mm

Maybe in Isengard (or JHuh) Wink
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#9
Lost way too much time with 14.2 so this won't be available for 15 (most likely) :/
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#10
@twolaw : good job, it work well on library or film information but not on widgets Sad
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#11
Hi twolaw,

Thanks for the script, my solution to implementing it into the skin I use is as follows:

1) Created new button 'Aternative Duration' in Skin >> Settings >> General. (AltDuration)
2) Appended the following into variables.xml:

<variable name="MovieDuration">
<value condition="System.HasAddon(script.duration) + Skin.HasSetting(AltDuration)">$INFO[window.Property(Duration)]</value>
<value>$INFO[ListItem.Duration]</value>
</variable>

3) modified MyVideoNav and DialogVideoInfo as per the onload info in readme.
4) Replease Listitem(Duration) wirh $VAR(MovieDuration)

I've only replaced the Listitem in DialogVideoInfo but it all seems to be working fine when switching it on of off.

I'm a noob skinner so I'm sure there may be better ways but this is all I know at the moment.

Mike
SKIN: Aeon Madnox
RIP Schimi2k, we miss you.
When I grow up I want to be a skilled skinner
Thank me by ⬇ adding to my + reputation
Reply
#12
I did the same in MQ5 for Helix.

Works like a charm and greatly usefull for movies like The return of the King Extended edition... 4:23 oO !

BTW, would it be possible to have an option to have 4h23 as instead of 4:23 ?

Thanks again
Reply
#13
(2015-04-11, 18:57)Namoi Wrote: BTW, would it be possible to have an option to have 4h23 as instead of 4:23 ?

You can do it on line 31 in default.py. Adding an option just for this seems useless in my opinion.
Reply
#14
(2015-04-11, 16:24)Mike_Doc Wrote: Hi twolaw,

Thanks for the script, my solution to implementing it into the skin I use is as follows:

1) Created new button 'Aternative Duration' in Skin >> Settings >> General. (AltDuration)
2) Appended the following into variables.xml:

<variable name="MovieDuration">
<value condition="System.HasAddon(script.duration) + Skin.HasSetting(AltDuration)">$INFO[window.Property(Duration)]</value>
<value>$INFO[ListItem.Duration]</value>
</variable>

3) modified MyVideoNav and DialogVideoInfo as per the onload info in readme.
4) Replease Listitem(Duration) wirh $VAR(MovieDuration)

I've only replaced the Listitem in DialogVideoInfo but it all seems to be working fine when switching it on of off.

I'm a noob skinner so I'm sure there may be better ways but this is all I know at the moment.

Mike
Yes it looks smart, thanks for sharing !
I'm a noob too, i'm open to suggestions that could improve this addon.
Reply
#15
(2015-04-12, 12:22)twolaw Wrote:
(2015-04-11, 18:57)Namoi Wrote: BTW, would it be possible to have an option to have 4h23 as instead of 4:23 ?

You can do it on line 31 in default.py. Adding an option just for this seems useless in my opinion.

Great, that will do it Big Grin

Thanks
Reply

Logout Mark Read Team Forum Stats Members Help
[Release] Duration script - Display movies runtime in hours & minutes1