Skip to content

Commit 0926a7b

Browse files
committed
updated to axbmcuser v0.3.5
1 parent be29340 commit 0926a7b

File tree

5 files changed

+143
-39
lines changed

5 files changed

+143
-39
lines changed

README.md

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,38 @@
11
script.duration
22
===============
33

4-
Displays movies duration in hours and minutes instead of only minutes while navigating in Kodi movies library.
4+
Displays movies duration in hours and minutes instead of only minutes while navigating in Kodi movies library. Kodi skin has to be tweaked.
55

66
Exemple: __108 minutes__ is now displayed __1h48__.
77

88
When launched the script provides those properties :
99

10-
* `Window(videolibrary).Property(Duration)`
11-
* `Window(movieinformation).Property(Duration)`
10+
* `Window(Home).Property(Duration.HoursMinutes)`
11+
* `Window(Home).Property(Duration.Hours)`
12+
* `Window(Home).Property(Duration.Minutes)`
13+
* `Window(Home).Property(Duration.DBID)`
1214

13-
To use it in your skin, just call it this way :
15+
##Exemple of integration in Estuary skin
1416

15-
* `RunScript(script.duration,duration=$INFO[ListItem.Duration])` for a one shot request
16-
* `RunScript(script.duration,backend=True)` to run in background
17+
2 files need to be modified as follow :
1718

18-
##Integration in your skin
19-
20-
3 files need to be modified as follow :
21-
22-
###MyVideoNav.xml
23-
24-
Add `<onload>RunScript(script.duration,backend=True)</onload>` at the beginning.
25-
26-
###variables.xml
19+
###Variables.xml
2720

2821
Add this new variable at the end of the file (before the `</include>`) :
2922
```
30-
<variable name="MovieDuration">
31-
<value condition="System.HasAddon(script.duration)">$INFO[window.Property(Duration)]</value>
32-
<value>$INFO[ListItem.Duration]</value>
23+
<variable name="ItemDuration">
24+
<value condition="System.HasAddon(script.duration)+
25+
[Window.IsVisible(Videos) | Window.IsVisible(Movieinformation)] +
26+
!String.IsEmpty(Window(Home).Property(Duration.Hours)) +
27+
!String.IsEqual(Window(Home).Property(Duration.Hours),0) +
28+
!String.IsEmpty(Window(Home).Property(Duration.DBID)) + String.IsEqual(Window(Home).Property(Duration.DBID),ListItem.DBID)">$INFO[Window(Home).Property(Duration.HoursMinutes)]
29+
</value>
30+
<value>$INFO[ListItem.Duration] min</value>
3331
</variable>
3432
```
35-
Then, still in variables.xml, do those replacements :
36-
37-
`$INFO[ListItem.Duration]` replaced by `$VAR[MovieDuration]`
3833

39-
`$INFO[ListItem.Duration,, $LOCALIZE[12391]]` replaced by `$VAR[MovieDuration]`
34+
###Includes.xml
4035

41-
`$INFO[ListItem.Duration, • , $LOCALIZE[12391]]` replaced by ` • $VAR[MovieDuration]` (one space before and after the dot)
42-
43-
###DialogVideoInfo.xml
44-
45-
Add `<onload>RunScript(script.duration,duration=$INFO[ListItem.Duration])</onload>` at the beginning.
46-
47-
Replace `$INFO[ListItem.Duration]` with `$VAR[MovieDuration]`
36+
Replace `<label>$INFO[$PARAM[infolabel_prefix]ListItem.Duration]</label>` with `<label>$VAR[ItemDuration]</label>`
4837

4938
______________________
50-
51-
_This is my first kodi addon, for any suggestions, do not hesitate to email me :)_

addon.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.duration" name="Duration script" version="0.2" provider-name="Twolaw">
2+
<addon id="script.duration" name="Duration script" version="0.3.5" provider-name="Twolaw, axbmcuser">
33
<requires>
44
<import addon="xbmc.python" version="2.14.0"/>
55
</requires>
6-
<extension point="xbmc.python.script" library="default.py">
7-
<provides>executable</provides>
6+
<extension library="service.py" point="xbmc.service" start="login">
87
</extension>
98
<extension point="xbmc.addon.metadata">
10-
<language/>
119
<summary lang="en">Durations converter from MMM to H:MM</summary>
1210
<description lang="en">
1311
Displays movies durations in the format H:MM instead of MMM format. For exemple: 113 minutes will be converted in 1h53
@@ -29,11 +27,15 @@
2927
Consente di visualizzare filmati durate nel formato H: MM anziché in formato MMM. Per Esempio: 113 minuti saranno convertiti in 1h53
3028
</description>
3129
<platform>all</platform>
30+
<forum>http://forum.kodi.tv/showthread.php?tid=220753</forum>
3231
<website>https://github.com/twolaw/</website>
3332
<disclaimer lang="en">Your skin has to be tweaked to use this script.</disclaimer>
3433
<disclaimer lang="fr">Votre skin doit être modifié pour utiliser ce script.</disclaimer>
3534
<disclaimer lang="de">Ihre skin hat gezwickt, um dieses Skript verwenden werden.</disclaimer>
3635
<disclaimer lang="es">Su skin tiene que ser ajustado para utilizar este script.</disclaimer>
3736
<disclaimer lang="it">Il tuo skin deve essere ottimizzato per utilizzare questo script.</disclaimer>
37+
<assets>
38+
<icon>icon.png</icon>
39+
</assets>
3840
</extension>
3941
</addon>

changelog.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
v0.2
2-
Correction of crash when duration value isn't properly writen in database
1+
[B]0.3.5[/B] (2017-07-14)
2+
- Reworked script, changed/removed deprecated stuff
3+
- New property names (see description for details)
34

4-
v0.1
5-
Initial release.
5+
[B]0.3.4[/B] (2017-07-11)
6+
- ListItem.DBID is now also set - for verification purposes (Duration.DBID)
7+
8+
[B]0.3.3[/B] (2016-08-03)
9+
- Minor cleanup
10+
11+
[B]0.3.2[/B] (2016-07-23)
12+
- axbmcuser MOD: Fix for KODI 17 (Krypton): "videolibrary" renamed to "videos" [default.py]
13+
14+
[B]0.3.1[/B]
15+
- axbmcuser MOD: Minor improvements and optimizations
16+
17+
[B]0.3[/B]
18+
- axbmcuser MOD: Script now outputs H:MM
19+
20+
[B]0.2[/B]
21+
- Correction of crash when duration value isn't properly written in database
22+
23+
[B]0.1[/B]
24+
- Initial release

icon.png

-10.8 KB
Loading

service.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# -*- coding: UTF-8 -*-
2+
3+
import xbmc, xbmcaddon, xbmcgui
4+
5+
# Script constants
6+
__addon__ = xbmcaddon.Addon()
7+
__addonid__ = __addon__.getAddonInfo('id')
8+
__version__ = __addon__.getAddonInfo('version')
9+
__language__ = __addon__.getLocalizedString
10+
__cwd__ = __addon__.getAddonInfo('path')
11+
12+
def log(txt):
13+
if isinstance (txt,str):
14+
txt = txt.decode("utf-8")
15+
message = u'%s: %s' % (__addonid__, txt)
16+
xbmc.log(msg=message.encode("utf-8"), level=xbmc.LOGDEBUG)
17+
18+
def get_hours_and_minutes(minutes_string):
19+
try:
20+
full_minutes = int(minutes_string)
21+
minutes = full_minutes % 60
22+
hours = full_minutes // 60
23+
return str(hours) + 'h' + str(minutes).zfill(2)
24+
except:
25+
return ''
26+
27+
def get_hours_only(minutes_string):
28+
try:
29+
full_minutes = int(minutes_string)
30+
hours = full_minutes // 60
31+
return str(hours)
32+
except:
33+
return ''
34+
35+
def get_minutes_only(minutes_string):
36+
try:
37+
full_minutes = int(minutes_string)
38+
minutes = full_minutes % 60
39+
return str(minutes).zfill(2)
40+
except:
41+
return ''
42+
43+
class Main:
44+
def __init__( self ):
45+
log("version %s started" % __version__)
46+
self.run_backend()
47+
48+
def run_backend(self):
49+
self.previousitem = ""
50+
while 1:
51+
if ((xbmc.getCondVisibility("Window.IsActive(Videos)") and xbmc.getCondVisibility("Window.Is(Videos)")) or (xbmc.getCondVisibility("Window.IsActive(MovieInformation)") and xbmc.getCondVisibility("Window.Is(MovieInformation)"))) and not xbmc.getCondVisibility("Container.Scrolling"):
52+
self.selecteditem = xbmc.getInfoLabel("ListItem.DBID")
53+
if (self.selecteditem != self.previousitem):
54+
#xbmc.executebuiltin('Notification(Hello World,test,500)')
55+
self.previousitem = self.selecteditem
56+
57+
if (xbmc.getInfoLabel("ListItem.DBID") > -1 and not xbmc.getCondVisibility("ListItem.IsFolder")) and xbmc.getInfoLabel("ListItem.Duration") and int(float(xbmc.getInfoLabel("ListItem.Duration"))) > 0:
58+
self.duration = xbmc.getInfoLabel("ListItem.Duration")
59+
self.dbid = xbmc.getInfoLabel("ListItem.DBID")
60+
self.display_duration()
61+
else:
62+
my_container_id = xbmc.getInfoLabel("Window(Home).Property(Duration.WidgetContainerId)")
63+
my_container_window = xbmc.getInfoLabel("Window(Home).Property(Duration.WidgetContainerWindowName)")
64+
65+
if (my_container_id and my_container_window and (xbmc.getCondVisibility("Control.HasFocus("+my_container_id+")") and xbmc.getCondVisibility("Window.IsActive("+my_container_window+")") and xbmc.getCondVisibility("Window.Is("+my_container_window+")")) and not xbmc.getCondVisibility("Window.IsActive(Videos)") and not xbmc.getCondVisibility("Window.IsActive(MovieInformation)")) and not xbmc.getCondVisibility("Container("+my_container_id+").Scrolling"):
66+
#xbmc.executebuiltin('Notification(Hello World,'+my_container_id+' '+my_container_window+',500)')
67+
self.selecteditem = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.DBID")
68+
if (self.selecteditem != self.previousitem):
69+
self.previousitem = self.selecteditem
70+
if (xbmc.getInfoLabel("Container("+my_container_id+").ListItem.DBID") > -1 and not xbmc.getCondVisibility("Container("+my_container_id+").ListItem.IsFolder")) and xbmc.getInfoLabel("Container("+my_container_id+").ListItem.Duration") and int(float(xbmc.getInfoLabel("Container("+my_container_id+").ListItem.Duration"))) > 0:
71+
self.duration = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.Duration")
72+
self.dbid = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.DBID")
73+
self.display_duration()
74+
xbmc.sleep(200)
75+
76+
def display_duration(self):
77+
log('Converts: '+self.duration+' min')
78+
#xbmc.executebuiltin('Notification(Hello World,'+self.duration+' '+self.dbid+',250)')
79+
80+
# HoursMinutes
81+
hours_and_minutes = get_hours_and_minutes(self.duration)
82+
xbmc.executebuiltin('SetProperty(Duration.HoursMinutes,'+hours_and_minutes+',home)')
83+
# Hours
84+
hours_only = get_hours_only(self.duration)
85+
xbmc.executebuiltin('SetProperty(Duration.Hours,'+hours_only+',home)')
86+
# Minutes
87+
minutes_only = get_minutes_only(self.duration)
88+
xbmc.executebuiltin('SetProperty(Duration.Minutes,'+minutes_only+',home)')
89+
# DBID
90+
xbmc.executebuiltin('SetProperty(Duration.DBID,'+self.dbid+',home)')
91+
# InputDurationMinutes
92+
xbmc.executebuiltin('SetProperty(Duration.InputDurationMinutes,'+self.duration+',home)')
93+
94+
if (__name__ == "__main__"):
95+
Main()
96+
log('script finished.')

0 commit comments

Comments
 (0)