@@ -43,37 +43,40 @@ def get_minutes_only(minutes_string):
4343class 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