--- misc/xbmc/plugin.video.todic/default.py 2016/11/21 22:18:33 3142 +++ misc/xbmc/plugin.video.todic/default.py 2016/11/23 08:06:06 3143 @@ -115,14 +115,14 @@ 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() ): @@ -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")