Kodi Community Forum
[Release] Duration script - Display movies runtime in hours & minutes - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Service Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=152)
+---- Thread: [Release] Duration script - Display movies runtime in hours & minutes (/showthread.php?tid=220753)

Pages: 1 2 3 4


RE: [Release] Duration script - Display movies runtime in hours:minutes - rd1979 - 2015-04-13

(2015-04-07, 16:02)Martijn Wrote: @mkortstiege
imo this should be something that is by default available for skins

+1

Good to see you agree. Hopefully this can be done quickly and easily.


RE: [Release] Duration script - Display movies runtime in hours:minutes - Mike_Doc - 2015-04-20

Hi Twolaw,

My skin solution may no be the best, been away and just started looking at updating other views and can't seem to get it to work. My noob skills are the problem as I just need to figure out how and where to call your script. I'd like to run it for the focused item but I don't think <onfocus> is available. If anyone has a suggestion then please let me know?

Mike


RE: [Release] Duration script - Display movies runtime in hours:minutes - Piers - 2015-04-20

Nice work, I think I'll use this.


RE: [Release] Duration script - Display movies runtime in hours:minutes - twolaw - 2015-04-24

(2015-04-20, 09:18)Mike_Doc Wrote: Hi Twolaw,

My skin solution may no be the best, been away and just started looking at updating other views and can't seem to get it to work. My noob skills are the problem as I just need to figure out how and where to call your script. I'd like to run it for the focused item but I don't think <onfocus> is available. If anyone has a suggestion then please let me know?

Mike

Did you try <onfocus>XBMC.RunScript(script.duration,duration=$INFO[ListItem.Duration])</onfocus> ?


RE: [Release] Duration script - Display movies runtime in hours & minutes - Mike_Doc - 2015-04-25

Hi twolaw,

No luck with your suggestion. Will have to try and figure it out as only a couple of views where it fails to work now!

Mike.


RE: [Release] Duration script - Display movies runtime in hours & minutes - mcorcoran - 2015-05-12

Hey,

First off love the addon, one little bug I've run into is I think is if their isn't a proper runtime in the database it crashes for all the movies. Here's the error I get in my log:
Code:
21:06:39 T:139772222650112   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ValueError'>
                                            Error Contents: invalid literal for int() with base 10: ''
                                            Traceback (most recent call last):
                                              File "/storage/.kodi/addons/script.duration-master/default.py", line 77, in <module>
                                                Main()
                                              File "/storage/.kodi/addons/script.duration-master/default.py", line 34, in __init__
                                                self.run_backend()
                                              File "/storage/.kodi/addons/script.duration-master/default.py", line 63, in run_backend
                                                self.display_duration()
                                              File "/storage/.kodi/addons/script.duration-master/default.py", line 72, in display_duration
                                                readable_duration = in_hours_and_min(self.duration)
                                              File "/storage/.kodi/addons/script.duration-master/default.py", line 19, in in_hours_and_min
                                                full_minutes = int(minutes_string)
                                            ValueError: invalid literal for int() with base 10: ''
                                            -->End of Python script error report<--
Let me know if you need more information.


RE: [Release] Duration script - Display movies runtime in hours & minutes - mikebzh44 - 2015-05-12

You can change in_hours_and_min function by editing /storage/.kodi/addons/script.duration-master/default.py and adding "try" "except" blocks :

Code:
def in_hours_and_min(minutes_string):
    try:
        full_minutes = int(minutes_string)
        minutes = full_minutes % 60
        hours   = full_minutes // 60
        return str(hours) + 'h' + str(minutes).zfill(2)
    except:
        return '--h--'

Take care of the indentation because python use it Wink


RE: [Release] Duration script - Display movies runtime in hours & minutes - mcorcoran - 2015-05-12

Great, thanks for the quick reply!


RE: [Release] Duration script - Display movies runtime in hours & minutes - twolaw - 2015-05-20

Thank you for your help, update is done to prevent this crash situation.


RE: [Release] Duration script - Display movies runtime in hours & minutes - Gade - 2015-05-22

Thanks for this cool script.

I'll add it to the Rapier skin Smile

Cheers
Gade


RE: [Release] Duration script - Display movies runtime in hours & minutes - Gade - 2015-05-22

In your addon.xml you have 2
Code:
</description>
tags in line 22 and 23.


RE: [Release] Duration script - Display movies runtime in hours & minutes - twolaw - 2015-05-22

(2015-05-22, 14:57)Gade Wrote: In your addon.xml you have 2
Code:
</description>
tags in line 22 and 23.
Fixed, thanks!


RE: [Release] Duration script - Display movies runtime in hours & minutes - Guilouz - 2015-07-22

I can't use this with container like $INFO(Container(301).ListItem.Duration), normal ?

Duration it's ok with $VAR[MovieDuration] (for $INFO[ListItem.Duration]). What is the code for Container ?


RE: [Release] Duration script - Display movies runtime in hours & minutes - BugRaider84 - 2015-08-08

Hi twolaw,

thanks for your script, great work!

enclosed my idea, hope you like it:

Change:
Code:
full_minutes = int(minutes_string)
        minutes = full_minutes % 60
        hours   = full_minutes // 60
        return str(hours) + 'h' + str(minutes).zfill(2)

Into:
Code:
full_minutes = int(minutes_string)
        minutes = full_minutes % 60
        hours   = full_minutes // 60
        return str(hours) + 'h ' + str(minutes) + 'm'.zfill(1)

I have to tell you that I have no plan in coding, I just simply knew where to look (prior posts) and changed it by trial and error Tongue
So if I did something wrong here please let me know!
So far I couldn't find any complications...

Results:

Image

Image


RE: [Release] Duration script - Display movies runtime in hours & minutes - twolaw - 2015-08-20

Your code looks strange. Why do you need to zfill the 'm' string ?
As I said, given that everybody have a preference regarding how to display duration, i won't change it or give an choice option for such a thing. Just edit your own file like you did. Smile