本文整理汇总了Python中utilities.getSettingAsBool函数的典型用法代码示例。如果您正苦于以下问题:Python getSettingAsBool函数的具体用法?Python getSettingAsBool怎么用?Python getSettingAsBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSettingAsBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
sync = Sync(show_progress=self._isManual, run_silent=self._runSilent, api=globals.traktapi)
sync.sync()
if utilities.getSettingAsBool('tagging_enable') and utilities.getSettingAsBool('tagging_tag_after_sync'):
q = queue.SqliteQueue()
q.append({'action': 'updateTags'})
示例2: syncCheck
def syncCheck(self, media_type):
if media_type == 'movies':
return utilities.getSettingAsBool('add_movies_to_trakt') or utilities.getSettingAsBool('trakt_movie_playcount') or utilities.getSettingAsBool('xbmc_movie_playcount') or utilities.getSettingAsBool('clean_trakt_movies')
else:
return utilities.getSettingAsBool('add_episodes_to_trakt') or utilities.getSettingAsBool('trakt_episode_playcount') or utilities.getSettingAsBool('xbmc_episode_playcount') or utilities.getSettingAsBool('clean_trakt_episodes')
return False
示例3: __scrobble
def __scrobble(self, status):
if not self.curVideoInfo:
return
logger.debug("scrobble()")
scrobbleMovieOption = utilities.getSettingAsBool("scrobble_movie")
scrobbleEpisodeOption = utilities.getSettingAsBool("scrobble_episode")
watchedPercent = self.__calculateWatchedPercent()
if utilities.isMovie(self.curVideo["type"]) and scrobbleMovieOption:
response = self.traktapi.scrobbleMovie(self.curVideoInfo, watchedPercent, status)
if not response is None:
self.__scrobbleNotification(response)
logger.debug("Scrobble response: %s" % str(response))
return response
elif utilities.isEpisode(self.curVideo["type"]) and scrobbleEpisodeOption:
if self.isMultiPartEpisode:
logger.debug(
"Multi-part episode, scrobbling part %d of %d."
% (self.curMPEpisode + 1, self.curVideo["multi_episode_count"])
)
adjustedDuration = int(self.videoDuration / self.curVideo["multi_episode_count"])
watchedPercent = ((self.watchedTime - (adjustedDuration * self.curMPEpisode)) / adjustedDuration) * 100
response = self.traktapi.scrobbleEpisode(self.traktShowSummary, self.curVideoInfo, watchedPercent, status)
if response is not None:
self.__scrobbleNotification(response)
logger.debug("Scrobble response: %s" % str(response))
return response
示例4: __init__
def __init__(self, show_progress=False, api=None):
self.traktapi = api
self.show_progress = show_progress
self.notify = utilities.getSettingAsBool('show_sync_notifications')
self.simulate = utilities.getSettingAsBool('simulate_sync')
if self.simulate:
Debug("[Sync] Sync is configured to be simulated.")
示例5: __init__
def __init__(self, show_progress=False, api=None):
self.traktapi = api
self.show_progress = show_progress
self.notify = utilities.getSettingAsBool('show_sync_notifications')
self.simulate = utilities.getSettingAsBool('simulate_sync')
if self.simulate:
Debug("[Sync] Sync is configured to be simulated.")
if self.show_progress:
progress.create('%s %s' % (utilities.getString(1400), utilities.getString(1402)), line1=' ', line2=' ', line3=' ')
示例6: __init__
def __init__(self, show_progress=False, run_silent=False, library="all", api=None):
self.traktapi = api
self.show_progress = show_progress
self.run_silent = run_silent
self.library = library
if self.show_progress and self.run_silent:
logger.debug("Sync is being run silently.")
self.sync_on_update = utilities.getSettingAsBool('sync_on_update')
self.notify = utilities.getSettingAsBool('show_sync_notifications')
self.notify_during_playback = not (xbmc.Player().isPlayingVideo() and utilities.getSettingAsBool("hide_notifications_playback"))
示例7: watching
def watching(self):
if not self.isPlaying:
return
if not self.curVideoInfo:
return
Debug("[Scrobbler] watching()")
self.update(True)
duration = self.videoDuration / 60
watchedPercent = (self.watchedTime / self.videoDuration) * 100
if self.isMultiPartEpisode:
Debug("[Scrobbler] Multi-part episode, watching part %d of %d." % (
self.curMPEpisode + 1, self.curVideo['multi_episode_count']))
# recalculate watchedPercent and duration for multi-part
adjustedDuration = int(self.videoDuration / self.curVideo['multi_episode_count'])
duration = adjustedDuration / 60
watchedPercent = ((self.watchedTime - (adjustedDuration * self.curMPEpisode)) / adjustedDuration) * 100
response = 'yep'
if response != None:
if self.curVideoInfo['tvdb_id'] is None:
if 'status' in response and response['status'] == "success":
if 'show' in response and 'tvdb_id' in response['show']:
self.curVideoInfo['tvdb_id'] = response['show']['tvdb_id']
if 'id' in self.curVideo and utilities.getSettingAsBool('update_tvdb_id'):
req = {"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.SetTVShowDetails",
"params": {"tvshowid": self.curVideoInfo['tvshowid'],
"imdbnumber": self.curVideoInfo['tvdb_id']}}
utilities.xbmcJsonRequest(req)
# get summary data now if we are rating this episode
if utilities.getSettingAsBool('rate_episode') and self.traktSummaryInfo is None:
self.traktSummaryInfo = self.traktapi.getEpisodeSummary(self.curVideoInfo['tvdb_id'],
self.curVideoInfo['season'],
self.curVideoInfo['episode'])
Debug("[Scrobbler] Watch response: %s" % str(response))
match = utilities.getEpisodeDetailsFromXbmc(self.curMPEpisode, ['showtitle', 'season', 'episode', 'tvshowid', 'uniqueid'])
else:
match = utilities.getEpisodeDetailsFromXbmc(self.curVideo['id'], ['showtitle', 'season', 'episode', 'tvshowid', 'uniqueid'])
elif 'showtitle' in self.curVideoData and 'season' in self.curVideoData and 'episode' in self.curVideoData:
match = {}
match['tvdb_id'] = None
match['year'] = None
match['showtitle'] = self.curVideoData['showtitle']
match['season'] = self.curVideoData['season']
match['episode'] = self.curVideoData['episode']
match['uniqueid'] = None
if match == None:
return
示例8: stoppedWatching
def stoppedWatching(self):
Debug("[Scrobbler] stoppedWatching()")
scrobbleMovieOption = utilities.getSettingAsBool("scrobble_movie")
scrobbleEpisodeOption = utilities.getSettingAsBool("scrobble_episode")
if utilities.isMovie(self.curVideo['type']) and scrobbleMovieOption:
response = self.traktapi.cancelWatchingMovie()
if response != None:
Debug("[Scrobbler] Cancel watch response: %s" % str(response))
elif utilities.isEpisode(self.curVideo['type']) and scrobbleEpisodeOption:
response = self.traktapi.cancelWatchingEpisode()
if response != None:
Debug("[Scrobbler] Cancel watch response: %s" % str(response))
示例9: _dispatch
def _dispatch(self, data):
try:
logger.debug("Dispatch: %s" % data)
action = data['action']
if action == 'started':
del data['action']
self.scrobbler.playbackStarted(data)
elif action == 'ended' or action == 'stopped':
self.scrobbler.playbackEnded()
elif action == 'paused':
self.scrobbler.playbackPaused()
elif action == 'resumed':
self.scrobbler.playbackResumed()
elif action == 'seek' or action == 'seekchapter':
self.scrobbler.playbackSeek()
elif action == 'databaseUpdated':
if utilities.getSettingAsBool('sync_on_update'):
logger.debug("Performing sync after library update.")
self.doSync()
elif action == 'databaseCleaned':
if utilities.getSettingAsBool('sync_on_update') and (utilities.getSettingAsBool('clean_trakt_movies') or utilities.getSettingAsBool('clean_trakt_episodes')):
logger.debug("Performing sync after library clean.")
self.doSync()
elif action == 'settingsChanged':
logger.debug("Settings changed, reloading.")
globals.traktapi.updateSettings()
elif action == 'markWatched':
del data['action']
self.doMarkWatched(data)
elif action == 'manualRating':
ratingData = data['ratingData']
self.doManualRating(ratingData)
elif action == 'addtowatchlist': # add to watchlist
del data['action']
self.doAddToWatchlist(data)
elif action == 'manualSync':
if not self.syncThread.isAlive():
logger.debug("Performing a manual sync.")
self.doSync(manual=True, silent=data['silent'], library=data['library'])
else:
logger.debug("There already is a sync in progress.")
elif action == 'settings':
utilities.showSettings()
elif action == 'scanStarted':
pass
else:
logger.debug("Unknown dispatch action, '%s'." % action)
except Exception as ex:
message = utilities.createError(ex)
logger.fatal(message)
示例10: __preFetchUserRatings
def __preFetchUserRatings(self, result):
if result:
if utilities.isMovie(self.curVideo['type']) and utilities.getSettingAsBool('rate_movie'):
# pre-get summary information, for faster rating dialog.
logger.debug("Movie rating is enabled, pre-fetching summary information.")
self.curVideoInfo = result['movie']
self.curVideoInfo['user'] = {'ratings': self.traktapi.getMovieRatingForUser(result['movie']['ids']['trakt'], 'trakt')}
elif utilities.isEpisode(self.curVideo['type']) and utilities.getSettingAsBool('rate_episode'):
# pre-get summary information, for faster rating dialog.
logger.debug("Episode rating is enabled, pre-fetching summary information.")
self.curVideoInfo = result['episode']
self.curVideoInfo['user'] = {'ratings': self.traktapi.getEpisodeRatingForUser(result['show']['ids']['trakt'],
self.curVideoInfo['season'], self.curVideoInfo['number'], 'trakt')}
logger.debug('Pre-Fetch result: %s; Info: %s' % (result, self.curVideoInfo))
示例11: scrobble
def scrobble(self):
if not self.curVideoInfo:
return
Debug("[Scrobbler] scrobble()")
scrobbleMovieOption = utilities.getSettingAsBool("scrobble_movie")
scrobbleEpisodeOption = utilities.getSettingAsBool("scrobble_episode")
duration = self.videoDuration / 60
watchedPercent = (self.watchedTime / self.videoDuration) * 100
if utilities.isMovie(self.curVideo["type"]) and scrobbleMovieOption:
response = self.traktapi.scrobbleMovie(self.curVideoInfo, duration, watchedPercent)
if not response is None and "status" in response:
if response["status"] == "success":
self.watchlistTagCheck()
Debug("[Scrobbler] Scrobble response: %s" % str(response))
elif response["status"] == "failure":
if response["error"].startswith("scrobbled") and response["error"].endswith("already"):
Debug("[Scrobbler] Movie was just recently scrobbled, attempting to cancel watching instead.")
self.stoppedWatching()
elif response["error"] == "movie not found":
Debug(
"[Scrobbler] Movie '%s' was not found on trakt.tv, possible malformed XBMC metadata."
% self.curVideoInfo["title"]
)
elif utilities.isEpisode(self.curVideo["type"]) and scrobbleEpisodeOption:
if self.isMultiPartEpisode:
Debug(
"[Scrobbler] Multi-part episode, scrobbling part %d of %d."
% (self.curMPEpisode + 1, self.curVideo["multi_episode_count"])
)
adjustedDuration = int(self.videoDuration / self.curVideo["multi_episode_count"])
duration = adjustedDuration / 60
watchedPercent = ((self.watchedTime - (adjustedDuration * self.curMPEpisode)) / adjustedDuration) * 100
response = self.traktapi.scrobbleEpisode(self.curVideoInfo, duration, watchedPercent)
if not response is None and "status" in response:
if response["status"] == "success":
Debug("[Scrobbler] Scrobble response: %s" % str(response))
elif response["status"] == "failure":
if response["error"].startswith("scrobbled") and response["error"].endswith("already"):
Debug("[Scrobbler] Episode was just recently scrobbled, attempting to cancel watching instead.")
self.stoppedWatching()
elif response["error"] == "show not found":
Debug(
"[Scrobbler] Show '%s' was not found on trakt.tv, possible malformed XBMC metadata."
% self.curVideoInfo["showtitle"]
)
示例12: watching
def watching(self):
if not self.isPlaying:
return
if not self.curVideoInfo:
return
Debug("[Scrobbler] watching()")
scrobbleMovieOption = utilities.getSettingAsBool('scrobble_movie')
scrobbleEpisodeOption = utilities.getSettingAsBool('scrobble_episode')
self.update(True)
duration = self.videoDuration / 60
watchedPercent = (self.watchedTime / self.videoDuration) * 100
if utilities.isMovie(self.curVideo['type']) and scrobbleMovieOption:
response = self.traktapi.watchingMovie(self.curVideoInfo, duration, watchedPercent)
if response != None:
if self.curVideoInfo['imdbnumber'] is None:
if 'status' in response and response['status'] == "success":
if 'movie' in response and 'imdb_id' in response['movie']:
self.curVideoInfo['imdbnumber'] = response['movie']['imdb_id']
# get summary data now if we are rating this movie
if utilities.getSettingAsBool('rate_movie') and self.traktSummaryInfo is None:
self.traktSummaryInfo = self.traktapi.getMovieSummary(self.curVideoInfo['imdbnumber'])
Debug("[Scrobbler] Watch response: %s" % str(response))
elif utilities.isEpisode(self.curVideo['type']) and scrobbleEpisodeOption:
if self.isMultiPartEpisode:
Debug("[Scrobbler] Multi-part episode, watching part %d of %d." % (self.curMPEpisode + 1, self.curVideo['multi_episode_count']))
# recalculate watchedPercent and duration for multi-part
adjustedDuration = int(self.videoDuration / self.curVideo['multi_episode_count'])
duration = adjustedDuration / 60
watchedPercent = ((self.watchedTime - (adjustedDuration * self.curMPEpisode)) / adjustedDuration) * 100
response = self.traktapi.watchingEpisode(self.curVideoInfo, duration, watchedPercent)
if response != None:
if self.curVideoInfo['tvdb_id'] is None:
if 'status' in response and response['status'] == "success":
if 'show' in response and 'tvdb_id' in response['show']:
self.curVideoInfo['tvdb_id'] = response['show']['tvdb_id']
# get summary data now if we are rating this episode
if utilities.getSettingAsBool('rate_episode') and self.traktSummaryInfo is None:
self.traktSummaryInfo = self.traktapi.getEpisodeSummary(self.curVideoInfo['tvdb_id'], self.curVideoInfo['season'], self.curVideoInfo['episode'])
Debug("[Scrobbler] Watch response: %s" % str(response))
示例13: __traktLoadMoviesPlaybackProgress
def __traktLoadMoviesPlaybackProgress(self):
if utilities.getSettingAsBool('trakt_movie_playback') and not self.__isCanceled():
self.__updateProgress(25, line2=utilities.getString(32122))
logger.debug('[Movies Sync] Getting playback progress from Trakt.tv')
try:
traktProgressMovies = self.traktapi.getMoviePlaybackProgress()
except Exception:
logger.debug("[Movies Sync] Invalid Trakt.tv playback progress list, possible error getting data from Trakt, aborting Trakt.tv playback update.")
return False
i = 0
x = float(len(traktProgressMovies))
moviesProgress = {'movies': []}
for movie in traktProgressMovies:
i += 1
y = ((i / x) * 25) + 11
self.__updateProgress(int(y), line2=utilities.getString(32123) % (i, x))
#will keep the data in python structures - just like the KODI response
movie = movie.to_dict()
moviesProgress['movies'].append(movie)
self.__updateProgress(36, line2=utilities.getString(32124))
return moviesProgress
示例14: check
def check(self, id, rating=0):
ok1,ok3=None,None
db_rating=self._get(id)
title=titlesync(id)
if getSettingAsBool("silentoffline"):
if db_rating==None and rating>=0:
showMessage(__language__(30520),__language__(30522) % (str(rating)))
ok1=True
elif db_rating>=0 and rating!=db_rating:
showMessage(__language__(30520),__language__(30523) % (str(rating)))
ok3=True
elif db_rating!=None and rating==db_rating:
showMessage(__language__(30520),__language__(30524) % (str(rating)))
else:
if db_rating==None and rating>=0:
ok1=self.dialog.yesno(__language__(30520),__language__(30525) % (str(rating)), unicode(title))
elif db_rating and rating!=db_rating:
ok3=self.dialog.yesno(__language__(30520),__language__(30526) % (str(db_rating), str(rating)),unicode(title))
elif db_rating==0 and rating!=db_rating:
ok3=True
elif db_rating!=None and rating==db_rating:
showMessage(__language__(30520),__language__(30527) % (str(rating)))
if ok1:
self._add(id, rating)
return True
if ok3:
self._delete(id)
self._add(id, rating)
return True
示例15: __addMoviesToKodiWatched
def __addMoviesToKodiWatched(self, traktMovies, kodiMovies):
if utilities.getSettingAsBool('kodi_movie_playcount') and not self.__isCanceled():
updateKodiTraktMovies = copy.deepcopy(traktMovies)
updateKodiKodiMovies = copy.deepcopy(kodiMovies)
kodiMoviesToUpdate = self.__compareMovies(updateKodiTraktMovies, updateKodiKodiMovies, watched=True, restrict=True)
if len(kodiMoviesToUpdate) == 0:
self.__updateProgress(84, line2=utilities.getString(32088))
logger.debug("[Movies Sync] Kodi movie playcount is up to date.")
return
titles = ", ".join(["%s" % (m['title']) for m in kodiMoviesToUpdate])
logger.debug("[Movies Sync] %i movie(s) playcount will be updated in Kodi" % len(kodiMoviesToUpdate))
logger.debug("[Movies Sync] Movies to add: %s" % titles)
self.__updateProgress(73, line2=utilities.getString(32065) % len(kodiMoviesToUpdate))
#split movie list into chunks of 50
chunksize = 50
chunked_movies = utilities.chunks([{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": kodiMoviesToUpdate[i]['movieid'], "playcount": kodiMoviesToUpdate[i]['plays'], "lastplayed": utilities.convertUtcToDateTime(kodiMoviesToUpdate[i]['last_watched_at'])}, "id": i} for i in range(len(kodiMoviesToUpdate))], chunksize)
i = 0
x = float(len(kodiMoviesToUpdate))
for chunk in chunked_movies:
if self.__isCanceled():
return
i += 1
y = ((i / x) * 11) + 73
self.__updateProgress(int(y), line2=utilities.getString(32089) % ((i)*chunksize if (i)*chunksize < x else x, x))
utilities.kodiJsonRequest(chunk)
self.__updateProgress(84, line2=utilities.getString(32090) % len(kodiMoviesToUpdate))