def onPlayBackStopped(self): log_utils.log('Service: Playback Stopped') if self.tracked: # clear the playlist if SALTS was playing and only one item in playlist to # use playlist to determine playback method in get_sources pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) plugin_url = 'plugin://%s/' % (kodi.get_id()) if pl.size() == 1 and pl[0].getfilename().lower().startswith(plugin_url): log_utils.log('Service: Clearing Single Item SALTS Playlist', log_utils.LOGDEBUG) pl.clear() playedTime = float(self._lastPos) try: percent_played = int((playedTime / self._totalTime) * 100) except: percent_played = 0 # guard div by zero pTime = utils2.format_time(playedTime) tTime = utils2.format_time(self._totalTime) log_utils.log('Service: Played %s of %s total = %s%%' % (pTime, tTime, percent_played), log_utils.LOGDEBUG) if playedTime == 0 and self._totalTime == 999999: log_utils.log('Kodi silently failed to start playback', log_utils.LOGWARNING) elif playedTime >= 5: log_utils.log('Service: Setting bookmark on |%s|%s|%s| to %s seconds' % (self.trakt_id, self.season, self.episode, playedTime), log_utils.LOGDEBUG) db_connection.set_bookmark(self.trakt_id, playedTime, self.season, self.episode) if percent_played >= 75: if xbmc.getCondVisibility('System.HasAddon(script.trakt)'): run = 'RunScript(script.trakt, action=sync, silent=True)' xbmc.executebuiltin(run) self.reset()
def onPlayBackStopped(self): log_utils.log('Service: Playback Stopped') if self.tracked: # clear the playlist if SALTS was playing and only one item in playlist to # use playlist to determine playback method in get_sources pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) plugin_url = 'plugin://%s/' % (kodi.get_id()) if pl.size() == 1 and pl[0].getfilename().lower().startswith(plugin_url): log_utils.log('Service: Clearing Single Item SALTS Playlist', log_utils.LOGDEBUG) pl.clear() playedTime = float(self._lastPos) try: percent_played = int((playedTime / self._totalTime) * 100) except: percent_played = 0 # guard div by zero pTime = utils.format_time(playedTime) tTime = utils.format_time(self._totalTime) log_utils.log('Service: Played %s of %s total = %s%%' % (pTime, tTime, percent_played), log_utils.LOGDEBUG) if playedTime == 0 and self._totalTime == 999999: log_utils.log('Kodi silently failed to start playback', log_utils.LOGWARNING) elif playedTime >= 5: log_utils.log('Service: Setting bookmark on |%s|%s|%s| to %s seconds' % (self.trakt_id, self.season, self.episode, playedTime), log_utils.LOGDEBUG) db_connection.set_bookmark(self.trakt_id, playedTime, self.season, self.episode) if percent_played >= 75: if xbmc.getCondVisibility('System.HasAddon(script.trakt)'): run = 'RunScript(script.trakt, action=sync, silent=True)' xbmc.executebuiltin(run) self.reset()
def disable_global_cx(): global was_on if xbmc.getCondVisibility('System.HasAddon(plugin.program.super.favourites)'): active_plugin = xbmc.getInfoLabel('Container.PluginName') sf = xbmcaddon.Addon('plugin.program.super.favourites') if active_plugin == kodi.get_id(): if sf.getSetting('CONTEXT') == 'true': log_utils.log('Disabling Global CX while SALTS is active', log_utils.LOGDEBUG) was_on = True sf.setSetting('CONTEXT', 'false') elif was_on: log_utils.log('Re-enabling Global CX while SALTS is not active', log_utils.LOGDEBUG) sf.setSetting('CONTEXT', 'true') was_on = False