--- misc/xbmc/plugin.video.todic/default.py 2016/11/21 22:18:33 3142 +++ misc/xbmc/plugin.video.todic/default.py 2016/11/23 09:44:02 3146 @@ -3,7 +3,7 @@ ''' Todic plugin for XBMC - Version 0.0.17 + Version 0.0.18 ''' import sys @@ -115,17 +115,17 @@ self.stopped = True print "[TodicPlayer] : stopped" url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) - open_url(url) + open_url_safe(url) def onPlayBackEnded(self): self.stopped = True print "[TodicPlayer] : ended" url = __backend__ + "&action=playbacktime&subaction=ended&time=" - open_url(url) + open_url_safe(url) def tick(self): - if ( self.isPlaying() ): + if ( self.isPlaying() ): self.playingPosition = self.getTime() now = time() #print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) @@ -137,7 +137,7 @@ def reportPlaytime(self): url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) - open_url(url) + open_url_safe(url) print "[Todic] reportPlaytime:" + url @@ -162,12 +162,14 @@ return nodelist[0].childNodes[0].nodeValue + def SaveFile(path, data): file = open(path, 'w') file.write(data) file.close() + def open_url(url): req = urllib2.Request(url) content = urllib2.urlopen(req) @@ -176,6 +178,16 @@ return data +# wraps open url in a catch-all exception handler +# usefull for periodic back-reporting that should not interrupt the program flow +def open_url_safe(url): + try: + return open_url(url) + except: + print "Some error during open_url call to ", url + + + def rootMenu(): msg = open_url(__backend__ + "&action=messages") @@ -307,7 +319,7 @@ # kan ikke loade subtitles hvis foerend playeren koerer count = 0 while not xbmc.Player().isPlaying(): - xbmc.sleep(500) + xbmc.sleep(250) count += 1 if count > 10: break @@ -322,7 +334,7 @@ #Holder python kørernde indtil at det bliver bedt om at stoppe while (not xbmc.abortRequested): player.tick() - xbmc.sleep(100) + xbmc.sleep(250)