def countMovies(self, movies, collection=True): if len(movies) > 0: if 'in_collection' in movies[0]: return len(utilities.findAllInList(movies, 'in_collection', collection)) else: return len(movies) return 0
def syncEpisodes(self): if not self.show_progress and self.sync_on_update and self.notify and self.notify_during_playback: notification('%s %s' % (utilities.getString(1400), utilities.getString(1406)), utilities.getString(1420)) #Sync started if self.show_progress and not self.run_silent: progress.create("%s %s" % (utilities.getString(1400), utilities.getString(1406)), line1=" ", line2=" ", line3=" ") xbmcShows = self.xbmcLoadShows() if not isinstance(xbmcShows, list) and not xbmcShows: Debug("[Episodes Sync] XBMC show list is empty, aborting tv show Sync.") if self.show_progress and not self.run_silent: progress.close() return traktShows = self.traktLoadShows() if not isinstance(traktShows, list): Debug("[Episodes Sync] Error getting trakt.tv show list, aborting tv show sync.") if self.show_progress and not self.run_silent: progress.close() return if utilities.getSettingAsBool('add_episodes_to_trakt') and not self.isCanceled(): traktShowsAdd = self.compareShows(xbmcShows, traktShows) self.traktAddEpisodes(traktShowsAdd) if utilities.getSettingAsBool('trakt_episode_playcount') and not self.isCanceled(): traktShowsUpdate = self.compareShows(xbmcShows, traktShows, watched=True) self.traktUpdateEpisodes(traktShowsUpdate) if utilities.getSettingAsBool('xbmc_episode_playcount') and not self.isCanceled(): xbmcShowsUpadate = self.compareShows(traktShows, xbmcShows, watched=True, restrict=True) self.xbmcUpdateEpisodes(xbmcShowsUpadate) if utilities.getSettingAsBool('clean_trakt_episodes') and not self.isCanceled(): traktShowsRemove = self.compareShows(traktShows, xbmcShows) self.traktRemoveEpisodes(traktShowsRemove) if not self.show_progress and self.sync_on_update and self.notify and self.notify_during_playback: notification('%s %s' % (utilities.getString(1400), utilities.getString(1406)), utilities.getString(1421)) #Sync complete if not self.isCanceled() and self.show_progress and not self.run_silent: self.updateProgress(100, line1=" ", line2=utilities.getString(1442), line3=" ") progress.close() Debug("[Episodes Sync] Shows on trakt.tv (%d), shows in XBMC (%d)." % (len(utilities.findAllInList(traktShows, 'in_collection', True)), len(xbmcShows))) Debug("[Episodes Sync] Episodes on trakt.tv (%d), episodes in XBMC (%d)." % (self.countEpisodes(traktShows), self.countEpisodes(xbmcShows))) Debug("[Episodes Sync] Complete.")