[Release] Duration script - Display movies runtime in hours & minutes
#16
(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.
Reply
#17
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
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
#18
Nice work, I think I'll use this.
Please read the online manual (wiki) & FAQ (wiki) before posting.

Skins: Estuary | Xperience1080
Opinion: Never purchase HTC products
Reply
#19
(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> ?
Reply
#20
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.
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
#21
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.
Reply
#22
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
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
#23
Great, thanks for the quick reply!
Reply
#24
Thank you for your help, update is done to prevent this crash situation.
Reply
#25
Thanks for this cool script.

I'll add it to the Rapier skin Smile

Cheers
Gade
Reply
#26
In your addon.xml you have 2
Code:
</description>
tags in line 22 and 23.
Reply
#27
(2015-05-22, 14:57)Gade Wrote: In your addon.xml you have 2
Code:
</description>
tags in line 22 and 23.
Fixed, thanks!
Reply
#28
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 ?
 Estuary MOD V2 
Reply
#29
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
Reply
#30
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
Reply

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