Skip to content

Commit 838e57c

Browse files
authored
Merge pull request #1 from twolaw/0.3.7
Update to 0.3.7
2 parents 51ad81a + 59f39ce commit 838e57c

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

addon.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.duration" name="Duration script" version="0.3.5" provider-name="Twolaw, axbmcuser">
2+
<addon id="script.duration" name="Duration script" version="0.3.7" provider-name="Twolaw, axbmcuser">
33
<requires>
4-
<import addon="xbmc.python" version="2.14.0"/>
4+
<import addon="xbmc.python" version="2.24.0"/>
55
</requires>
66
<extension library="service.py" point="xbmc.service" start="login">
77
</extension>
@@ -38,4 +38,4 @@
3838
<icon>icon.png</icon>
3939
</assets>
4040
</extension>
41-
</addon>
41+
</addon>

changelog.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[B]0.3.7[/B] (2018-04-19)
2+
- Minor improvements and optimizations
3+
14
[B]0.3.5[/B] (2017-07-14)
25
- Reworked script, changed/removed deprecated stuff
36
- New property names (see description for details)
@@ -21,4 +24,4 @@
2124
- Correction of crash when duration value isn't properly written in database
2225

2326
[B]0.1[/B]
24-
- Initial release
27+
- Initial release

service.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,40 @@ def get_minutes_only(minutes_string):
4343
class Main:
4444
def __init__( self ):
4545
log("version %s started" % __version__)
46-
self.run_backend()
47-
48-
def run_backend(self):
4946
self.previousitem = ""
50-
while 1:
47+
self.monitor = xbmc.Monitor()
48+
self.run_service()
49+
50+
def run_service(self):
51+
while not self.monitor.abortRequested():
52+
if self.monitor.waitForAbort(0.2):
53+
break
5154
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"):
5255
self.selecteditem = xbmc.getInfoLabel("ListItem.DBID")
53-
if (self.selecteditem != self.previousitem):
56+
if (self.selecteditem and self.selecteditem != self.previousitem):
5457
#xbmc.executebuiltin('Notification(Hello World,test,500)')
5558
self.previousitem = self.selecteditem
5659

5760
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:
5861
self.duration = xbmc.getInfoLabel("ListItem.Duration")
5962
self.dbid = xbmc.getInfoLabel("ListItem.DBID")
60-
self.display_duration()
63+
self.set_duration_values()
6164
else:
6265
my_container_id = xbmc.getInfoLabel("Window(Home).Property(Duration.WidgetContainerId)")
6366
my_container_window = xbmc.getInfoLabel("Window(Home).Property(Duration.WidgetContainerWindowName)")
6467

6568
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"):
6669
#xbmc.executebuiltin('Notification(Hello World,'+my_container_id+' '+my_container_window+',500)')
6770
self.selecteditem = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.DBID")
68-
if (self.selecteditem != self.previousitem):
71+
if (self.selecteditem and self.selecteditem != self.previousitem):
6972
self.previousitem = self.selecteditem
7073
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:
7174
self.duration = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.Duration")
7275
self.dbid = xbmc.getInfoLabel("Container("+my_container_id+").ListItem.DBID")
73-
self.display_duration()
74-
xbmc.sleep(200)
76+
self.set_duration_values()
77+
#run_service end
7578

76-
def display_duration(self):
79+
def set_duration_values(self):
7780
log('Converts: '+self.duration+' min')
7881
#xbmc.executebuiltin('Notification(Hello World,'+self.duration+' '+self.dbid+',250)')
7982

0 commit comments

Comments
 (0)