本文整理汇总了Python中resources.lib.kodiUtilities.getSettingAsBool函数的典型用法代码示例。如果您正苦于以下问题:Python getSettingAsBool函数的具体用法?Python getSettingAsBool怎么用?Python getSettingAsBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSettingAsBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __deleteMoviesFromTraktCollection
def __deleteMoviesFromTraktCollection(self, traktMovies, kodiMovies, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('clean_trakt_movies') and not self.sync.IsCanceled():
removeTraktMovies = copy.deepcopy(traktMovies)
removeKodiMovies = copy.deepcopy(kodiMovies)
logger.debug("[Movies Sync] Starting to remove.")
traktMoviesToRemove = utilities.compareMovies(
removeTraktMovies, removeKodiMovies, kodiUtilities.getSettingAsBool("scrobble_fallback"))
utilities.sanitizeMovies(traktMoviesToRemove)
logger.debug("[Movies Sync] Compared movies, found %s to remove." % len(traktMoviesToRemove))
if len(traktMoviesToRemove) == 0:
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32091))
logger.debug("[Movies Sync] Trakt.tv movie collection is clean, no movies to remove.")
return
titles = ", ".join(["%s" % (m['title']) for m in traktMoviesToRemove])
logger.debug("[Movies Sync] %i movie(s) will be removed from Trakt.tv collection." % len(traktMoviesToRemove))
logger.debug("[Movies Sync] Movies removed: %s" % titles)
self.sync.UpdateProgress(fromPercent, line2=kodiUtilities.getString(32076) % len(traktMoviesToRemove))
moviesToRemove = {'movies': traktMoviesToRemove}
try:
self.sync.traktapi.removeFromCollection(moviesToRemove)
except Exception as ex:
message = utilities.createError(ex)
logging.fatal(message)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32092) % len(traktMoviesToRemove))
示例2: __addMoviesToTraktCollection
def __addMoviesToTraktCollection(self, kodiMovies, traktMovies, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('add_movies_to_trakt') and not self.sync.IsCanceled():
addTraktMovies = copy.deepcopy(traktMovies)
addKodiMovies = copy.deepcopy(kodiMovies)
traktMoviesToAdd = utilities.compareMovies(
addKodiMovies, addTraktMovies, kodiUtilities.getSettingAsBool("scrobble_fallback"))
utilities.sanitizeMovies(traktMoviesToAdd)
logger.debug("[Movies Sync] Compared movies, found %s to add." % len(traktMoviesToAdd))
if len(traktMoviesToAdd) == 0:
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32084))
logger.debug("[Movies Sync] Trakt.tv movie collection is up to date.")
return
titles = ", ".join(["%s" % (m['title']) for m in traktMoviesToAdd])
logger.debug("[Movies Sync] %i movie(s) will be added to Trakt.tv collection." % len(traktMoviesToAdd))
logger.debug("[Movies Sync] Movies to add : %s" % titles)
self.sync.UpdateProgress(fromPercent, line2=kodiUtilities.getString(32063) % len(traktMoviesToAdd))
moviesToAdd = {'movies': traktMoviesToAdd}
# logger.debug("Movies to add: %s" % moviesToAdd)
try:
self.sync.traktapi.addToCollection(moviesToAdd)
except Exception as ex:
message = utilities.createError(ex)
logging.fatal(message)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32085) % len(traktMoviesToAdd))
示例3: __scrobble
def __scrobble(self, status):
if not self.curVideoInfo:
return
logger.debug("scrobble()")
scrobbleMovieOption = kodiUtilities.getSettingAsBool('scrobble_movie')
scrobbleEpisodeOption = kodiUtilities.getSettingAsBool('scrobble_episode')
watchedPercent = self.__calculateWatchedPercent()
if utilities.isMovie(self.curVideo['type']) and scrobbleMovieOption:
response = self.traktapi.scrobbleMovie(self.curVideoInfo, watchedPercent, status)
if response is not None:
self.__scrobbleNotification(response)
logger.debug("Scrobble response: %s" % str(response))
return response
else:
logger.debug("Failed to scrobble movie: %s | %s | %s" % (self.curVideoInfo, watchedPercent, status))
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
logger.debug("scrobble sending show object: %s" % str(self.traktShowSummary))
logger.debug("scrobble sending episode object: %s" % str(self.curVideoInfo))
response = self.traktapi.scrobbleEpisode(self.traktShowSummary, self.curVideoInfo, watchedPercent, status)
if (kodiUtilities.getSettingAsBool('scrobble_secondary_title')):
logger.debug('[traktPlayer] Setting is enabled to try secondary show title, if necessary.')
# If there is an empty response, the reason might be that the title we have isn't the actual show title,
# but rather an alternative title. To handle this case, call the Trakt search function.
if response is None:
logger.debug("Searching for show title: %s" % self.traktShowSummary['title'])
# This text query API is basically the same as searching on the website. Works with alternative
# titles, unlike the scrobble function.
newResp = self.traktapi.getTextQuery(self.traktShowSummary['title'], "show", None)
if not newResp:
logger.debug("Empty Response from getTextQuery, giving up")
else:
logger.debug("Got Response from getTextQuery: %s" % str(newResp))
# We got something back. Have to assume the first show found is the right one; if there's more than
# one, there's no way to know which to use. Pull the primary title from the response (and the year,
# just because it's there).
showObj = {'title': newResp[0].title, 'year': newResp[0].year}
logger.debug("scrobble sending getTextQuery first show object: %s" % str(showObj))
# Now we can attempt the scrobble again, using the primary title this time.
response = self.traktapi.scrobbleEpisode(showObj, self.curVideoInfo, watchedPercent, status)
if response is not None:
self.__scrobbleNotification(response)
logger.debug("Scrobble response: %s" % str(response))
return response
else:
logger.debug("Failed to scrobble episode: %s | %s | %s | %s" % (self.traktShowSummary,
self.curVideoInfo, watchedPercent,
status))
示例4: __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 = getSettingAsBool('sync_on_update')
self.notify = getSettingAsBool('show_sync_notifications')
self.notify_during_playback = not (xbmc.Player().isPlayingVideo() and getSettingAsBool("hide_notifications_playback"))
示例5: __preFetchUserRatings
def __preFetchUserRatings(self, result):
if result:
if utilities.isMovie(self.curVideo['type']) and kodiUtilities.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 kodiUtilities.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))
示例6: _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 == 'scanFinished':
if kodiUtilities.getSettingAsBool('sync_on_update'):
logger.debug("Performing sync after library update.")
self.doSync()
elif action == 'databaseCleaned':
if kodiUtilities.getSettingAsBool('sync_on_update') and (kodiUtilities.getSettingAsBool('clean_trakt_movies') or kodiUtilities.getSettingAsBool('clean_trakt_episodes')):
logger.debug("Performing sync after library clean.")
self.doSync()
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':
kodiUtilities.showSettings()
elif action == 'auth_info':
xbmc.executebuiltin('Dialog.Close(all, true)')
# init traktapi class
globals.traktapi = traktAPI(True)
else:
logger.debug("Unknown dispatch action, '%s'." % action)
except Exception as ex:
message = utilities.createError(ex)
logger.fatal(message)
示例7: __addMoviesToKodiWatched
def __addMoviesToKodiWatched(self, traktMovies, kodiMovies, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('kodi_movie_playcount') and not self.sync.IsCanceled():
updateKodiTraktMovies = copy.deepcopy(traktMovies)
updateKodiKodiMovies = copy.deepcopy(kodiMovies)
kodiMoviesToUpdate = utilities.compareMovies(updateKodiTraktMovies, updateKodiKodiMovies, kodiUtilities.getSettingAsBool(
"scrobble_fallback"), watched=True, restrict=True)
if len(kodiMoviesToUpdate) == 0:
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.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.sync.UpdateProgress(fromPercent, line2=kodiUtilities.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.sync.IsCanceled():
return
i += 1
y = ((i / x) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line2=kodiUtilities.getString(32089) % ((i) * chunksize if (i) * chunksize < x else x, x))
kodiUtilities.kodiJsonRequest(chunk)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32090) % len(kodiMoviesToUpdate))
示例8: __scrobbleNotification
def __scrobbleNotification(self, info):
if not self.curVideoInfo:
return
if kodiUtilities.getSettingAsBool("scrobble_notification"):
s = utilities.getFormattedItemName(self.curVideo['type'], info[self.curVideo['type']])
kodiUtilities.notification(kodiUtilities.getString(32015), s)
示例9: __addMovieProgressToKodi
def __addMovieProgressToKodi(self, traktMovies, kodiMovies, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('trakt_movie_playback') and traktMovies and not self.sync.IsCanceled():
updateKodiTraktMovies = copy.deepcopy(traktMovies)
updateKodiKodiMovies = copy.deepcopy(kodiMovies)
kodiMoviesToUpdate = utilities.compareMovies(updateKodiTraktMovies['movies'], updateKodiKodiMovies, kodiUtilities.getSettingAsBool("scrobble_fallback"), restrict=True, playback=True)
if len(kodiMoviesToUpdate) == 0:
self.sync.UpdateProgress(toPercent, line1='', line2=kodiUtilities.getString(32125))
logger.debug("[Movies Sync] Kodi movie playbacks are up to date.")
return
logger.debug("[Movies Sync] %i movie(s) playbacks will be updated in Kodi" % len(kodiMoviesToUpdate))
self.sync.UpdateProgress(fromPercent, line1='', line2=kodiUtilities.getString(32126) % len(kodiMoviesToUpdate))
# need to calculate the progress in int from progress in percent from Trakt
# split movie list into chunks of 50
chunksize = 50
chunked_movies = utilities.chunks([{"jsonrpc": "2.0", "id": i, "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": kodiMoviesToUpdate[i]['movieid'], "resume": {"position": kodiMoviesToUpdate[i]['runtime'] / 100.0 * kodiMoviesToUpdate[i]['progress'], "total": kodiMoviesToUpdate[i]['runtime']}}} for i in range(len(kodiMoviesToUpdate))], chunksize)
i = 0
x = float(len(kodiMoviesToUpdate))
for chunk in chunked_movies:
if self.sync.IsCanceled():
return
i += 1
y = ((i / x) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line2=kodiUtilities.getString(32127) % ((i) * chunksize if (i) * chunksize < x else x, x))
kodiUtilities.kodiJsonRequest(chunk)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32128) % len(kodiMoviesToUpdate))
示例10: __traktLoadMoviesPlaybackProgress
def __traktLoadMoviesPlaybackProgress(self, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('trakt_movie_playback') and not self.sync.IsCanceled():
self.sync.UpdateProgress(fromPercent, line2=kodiUtilities.getString(32122))
logger.debug('[Movies Sync] Getting playback progress from Trakt.tv')
try:
traktProgressMovies = self.sync.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) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line2=kodiUtilities.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.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32124))
return moviesProgress
示例11: __traktLoadShowsPlaybackProgress
def __traktLoadShowsPlaybackProgress(self, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('trakt_episode_playback') and not self.sync.IsCanceled():
self.sync.UpdateProgress(fromPercent, line1=kodiUtilities.getString(1485), line2=kodiUtilities.getString(32119))
logger.debug('[Playback Sync] Getting playback progress from Trakt.tv')
try:
traktProgressShows = self.sync.traktapi.getEpisodePlaybackProgress()
except Exception as ex:
logger.debug("[Playback Sync] Invalid Trakt.tv progress list, possible error getting data from Trakt, aborting Trakt.tv playback update. Error: %s" % ex)
return False
i = 0
x = float(len(traktProgressShows))
showsProgress = {'shows': []}
for show in traktProgressShows:
i += 1
y = ((i / x) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line2=kodiUtilities.getString(32120) % (i, x))
# will keep the data in python structures - just like the KODI response
show = show.to_dict()
showsProgress['shows'].append(show)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32121))
return showsProgress
示例12: ratingCheck
def ratingCheck(media_type, summary_info, watched_time, total_time, playlist_length):
"""Check if a video should be rated and if so launches the rating dialog"""
logger.debug("Rating Check called for '%s'" % media_type)
if not kodiUtilities.getSettingAsBool("rate_%s" % media_type):
logger.debug("'%s' is configured to not be rated." % media_type)
return
if summary_info is None:
logger.debug("Summary information is empty, aborting.")
return
watched = (watched_time / total_time) * 100
if watched >= kodiUtilities.getSettingAsFloat("rate_min_view_time"):
if (playlist_length <= 1) or kodiUtilities.getSettingAsBool("rate_each_playlist_item"):
rateMedia(media_type, summary_info)
else:
logger.debug("Rate each playlist item is disabled.")
else:
logger.debug("'%s' does not meet minimum view time for rating (watched: %0.2f%%, minimum: %0.2f%%)" % (media_type, watched, kodiUtilities.getSettingAsFloat("rate_min_view_time")))
示例13: emit
def emit(self, record):
levels = {
logging.CRITICAL: xbmc.LOGFATAL,
logging.ERROR: xbmc.LOGERROR,
logging.WARNING: xbmc.LOGWARNING,
logging.INFO: xbmc.LOGINFO,
logging.DEBUG: xbmc.LOGDEBUG,
logging.NOTSET: xbmc.LOGNONE,
}
if getSettingAsBool('debug'):
try:
xbmc.log(self.format(record), levels[record.levelno])
except UnicodeEncodeError:
xbmc.log(self.format(record).encode('utf-8', 'ignore'), levels[record.levelno])
示例14: __syncShowsRatings
def __syncShowsRatings(self, traktShows, kodiShows, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('trakt_sync_ratings') and traktShows and not self.sync.IsCanceled():
updateKodiTraktShows = copy.deepcopy(traktShows)
updateKodiKodiShows = copy.deepcopy(kodiShows)
traktShowsToUpdate = self.__compareShows(updateKodiKodiShows, updateKodiTraktShows, rating=True)
if len(traktShowsToUpdate['shows']) == 0:
self.sync.UpdateProgress(toPercent, line1='', line2=kodiUtilities.getString(32181))
logger.debug("[Episodes Sync] Trakt show ratings are up to date.")
else:
logger.debug("[Episodes Sync] %i show(s) will have show ratings added on Trakt" % len(traktShowsToUpdate['shows']))
self.sync.UpdateProgress(fromPercent, line1='', line2=kodiUtilities.getString(32182) % len(traktShowsToUpdate['shows']))
self.sync.traktapi.addRating(traktShowsToUpdate)
# needs to be restricted, because we can't add a rating to an episode which is not in our Kodi collection
kodiShowsUpdate = self.__compareShows(updateKodiTraktShows, updateKodiKodiShows, rating=True, restrict = True)
if len(kodiShowsUpdate['shows']) == 0:
self.sync.UpdateProgress(toPercent, line1='', line2=kodiUtilities.getString(32176))
logger.debug("[Episodes Sync] Kodi show ratings are up to date.")
else:
logger.debug("[Episodes Sync] %i show(s) will have show ratings added in Kodi" % len(kodiShowsUpdate['shows']))
shows = []
for show in kodiShowsUpdate['shows']:
shows.append({'tvshowid': show['tvshowid'], 'rating': show['rating']})
# split episode list into chunks of 50
chunksize = 50
chunked_episodes = utilities.chunks([{"jsonrpc": "2.0", "id": i, "method": "VideoLibrary.SetTVShowDetails",
"params": {"tvshowid": shows[i]['tvshowid'],
"userrating": shows[i]['rating']}} for i in range(len(shows))],
chunksize)
i = 0
x = float(len(shows))
for chunk in chunked_episodes:
if self.sync.IsCanceled():
return
i += 1
y = ((i / x) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line1='', line2=kodiUtilities.getString(32177) % ((i) * chunksize if (i) * chunksize < x else x, x))
kodiUtilities.kodiJsonRequest(chunk)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32178) % len(shows))
示例15: __syncMovieRatings
def __syncMovieRatings(self, traktMovies, kodiMovies, fromPercent, toPercent):
if kodiUtilities.getSettingAsBool('trakt_sync_ratings') and traktMovies and not self.sync.IsCanceled():
updateKodiTraktMovies = copy.deepcopy(traktMovies)
updateKodiKodiMovies = copy.deepcopy(kodiMovies)
traktMoviesToUpdate = utilities.compareMovies(updateKodiKodiMovies, updateKodiTraktMovies, kodiUtilities.getSettingAsBool("scrobble_fallback"), rating=True)
if len(traktMoviesToUpdate) == 0:
self.sync.UpdateProgress(toPercent, line1='', line2=kodiUtilities.getString(32179))
logger.debug("[Movies Sync] Trakt movie ratings are up to date.")
else:
logger.debug("[Movies Sync] %i movie(s) ratings will be updated on Trakt" % len(traktMoviesToUpdate))
self.sync.UpdateProgress(fromPercent, line1='', line2=kodiUtilities.getString(32180) % len(traktMoviesToUpdate))
moviesRatings = {'movies': traktMoviesToUpdate}
self.sync.traktapi.addRating(moviesRatings)
kodiMoviesToUpdate = utilities.compareMovies(updateKodiTraktMovies, updateKodiKodiMovies, kodiUtilities.getSettingAsBool(
"scrobble_fallback"), restrict=True, rating=True)
if len(kodiMoviesToUpdate) == 0:
self.sync.UpdateProgress(toPercent, line1='', line2=kodiUtilities.getString(32169))
logger.debug("[Movies Sync] Kodi movie ratings are up to date.")
else:
logger.debug("[Movies Sync] %i movie(s) ratings will be updated in Kodi" % len(kodiMoviesToUpdate))
self.sync.UpdateProgress(fromPercent, line1='', line2=kodiUtilities.getString(32170) % len(kodiMoviesToUpdate))
# split movie list into chunks of 50
chunksize = 50
chunked_movies = utilities.chunks([{"jsonrpc": "2.0", "id": i, "method": "VideoLibrary.SetMovieDetails",
"params": {"movieid": kodiMoviesToUpdate[i]['movieid'],
"userrating": kodiMoviesToUpdate[i]['rating']}} for i in range(len(kodiMoviesToUpdate))],
chunksize)
i = 0
x = float(len(kodiMoviesToUpdate))
for chunk in chunked_movies:
if self.sync.IsCanceled():
return
i += 1
y = ((i / x) * (toPercent-fromPercent)) + fromPercent
self.sync.UpdateProgress(int(y), line2=kodiUtilities.getString(32171) % ((i) * chunksize if (i) * chunksize < x else x, x))
kodiUtilities.kodiJsonRequest(chunk)
self.sync.UpdateProgress(toPercent, line2=kodiUtilities.getString(32172) % len(kodiMoviesToUpdate))