当前位置: 首页>>代码示例>>Python>>正文


Python utilities.getString函数代码示例

本文整理汇总了Python中utilities.getString函数的典型用法代码示例。如果您正苦于以下问题:Python getString函数的具体用法?Python getString怎么用?Python getString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: traktUpdateMovies

	def traktUpdateMovies(self, movies):
		if len(movies) == 0:
			self.updateProgress(60, line2=utilities.getString(1469))
			Debug("[Movies Sync] trakt.tv movie playcount is up to date")
			return
		
		titles = ", ".join(["%s (%s)" % (m['title'], m['imdb_id']) for m in movies])
		Debug("[Movies Sync] %i movie(s) playcount will be updated on trakt.tv" % len(movies))
		Debug("[Movies Sync] Movies updated: %s" % titles)

		self.updateProgress(40, line2="%i %s" % (len(movies), utilities.getString(1428)))

		# Send request to update playcounts on trakt.tv
		chunked_movies = utilities.chunks([self.sanitizeMovieData(movie) for movie in movies], 50)
		i = 0
		x = float(len(chunked_movies))
		for chunk in chunked_movies:
			if self.isCanceled():
				return
			params = {'movies': chunk}
			if self.simulate:
				Debug("[Movies Sync] %s" % str(params))
			else:
				self.traktapi.updateSeenMovie(params)

			i = i + 1
			y = ((i / x) * 20) + 40
			self.updateProgress(int(y), line2=utilities.getString(1478))

		self.updateProgress(60, line2=utilities.getString(1470) % len(movies))
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:30,代码来源:sync.py

示例2: xbmcUpdateEpisodes

	def xbmcUpdateEpisodes(self, shows):
		if len(shows) == 0:
			self.updateProgress(82, line1=utilities.getString(1441), line2=utilities.getString(1493))
			Debug("[Episodes Sync] XBMC episode playcounts are up to date.")
			return

		Debug("[Episodes Sync] %i show(s) shows are missing playcounts on XBMC" % len(shows))
		for s in ["%s" % self.getShowAsString(s, short=True) for s in shows]:
			Debug("[Episodes Sync] Episodes updated: %s" % s)

		self.updateProgress(64, line1=utilities.getString(1441), line2="%i %s" % (len(shows), utilities.getString(1439)), line3=" ")

		episodes = []
		for show in shows:
			for season in show['seasons']:
				for episode in show['seasons'][season]:
					episodes.append({'episodeid': show['seasons'][season][episode]['id'], 'playcount': 1})

		#split episode list into chunks of 50
		chunked_episodes = utilities.chunks([{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": episodes[i], "id": i} for i in range(len(episodes))], 50)
		i = 0
		x = float(len(chunked_episodes))
		for chunk in chunked_episodes:
			if self.isCanceled():
				return
			if self.simulate:
				Debug("[Episodes Sync] %s" % str(chunk))
			else:
				utilities.xbmcJsonRequest(chunk)

			i = i + 1
			y = ((i / x) * 18) + 64
			self.updateProgress(int(y), line2=utilities.getString(1494))

		self.updateProgress(82, line2=utilities.getString(1495) % len(episodes))
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:35,代码来源:sync.py

示例3: __deleteMoviesFromTraktCollection

	def __deleteMoviesFromTraktCollection(self, traktMovies, kodiMovies):

		if utilities.getSettingAsBool('clean_trakt_movies') and not self.__isCanceled():
			removeTraktMovies = copy.deepcopy(traktMovies)
			removeKodiMovies = copy.deepcopy(kodiMovies)

			logger.debug("[Movies Sync] Starting to remove.")
			traktMoviesToRemove = self.__compareMovies(removeTraktMovies, removeKodiMovies)
			self.sanitizeMovies(traktMoviesToRemove)
			logger.debug("[Movies Sync] Compared movies, found %s to remove." % len(traktMoviesToRemove))

			if len(traktMoviesToRemove) == 0:
				self.__updateProgress(60, line2=utilities.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.__updateProgress(49, line2=utilities.getString(32076) % len(traktMoviesToRemove))

			moviesToRemove = {'movies': traktMoviesToRemove}
			try:
				self.traktapi.removeFromCollection(moviesToRemove)
			except Exception as ex:
				message = utilities.createError(ex)
				logging.fatal(message)

			self.__updateProgress(60, line2=utilities.getString(32092) % len(traktMoviesToRemove))
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:30,代码来源:sync.py

示例4: traktAddEpisodes

	def traktAddEpisodes(self, shows):
		if len(shows) == 0:
			Debug("[Episodes Sync] trakt.tv episode collection is up to date.")
			return

		Debug("[Episodes Sync] %i show(s) have episodes (%d) to be added to your trakt.tv collection." % (len(shows), self.countEpisodes(shows)))
		for show in shows:
			Debug("[Episodes Sync] Episodes added: %s" % self.getShowAsString(show, short=True))
		
		if self.show_progress:
			progress.update(35, line1=utilities.getString(1435), line2='%i %s' % (len(shows), utilities.getString(1436)))

		for show in shows:
			if self.isCanceled():
				return

			epCount = self.countEpisodes([show])
			title = show['title'].encode('utf-8', 'ignore')

			if self.show_progress:
				progress.update(45, line1=utilities.getString(1435), line2=title, line3='%i %s' % (epCount, utilities.getString(1437)))

			s = self.traktFormatShow(show)
			if self.simulate:
				Debug("[Episodes Sync] %s" % str(s))
			else:
				self.traktapi.addEpisode(s)
开发者ID:chx0003,项目名称:script.trakt,代码行数:27,代码来源:sync.py

示例5: traktRemoveEpisodes

	def traktRemoveEpisodes(self, shows):
		if len(shows) == 0:
			Debug('[Episodes Sync] trakt.tv episode collection is clean')
			return

		Debug("[Episodes Sync] %i show(s) will have episodes removed from trakt.tv collection." % len(shows))
		for show in shows:
			Debug("[Episodes Sync] Episodes removed: %s" % self.getShowAsString(show, short=True))

		if self.show_progress:
			progress.update(90, line1=utilities.getString(1445), line2='%i %s' % (len(shows), utilities.getString(1446)))

		for show in shows:
			if self.isCanceled():
				return

			epCount = self.countEpisodes([show])
			title = show['title'].encode('utf-8', 'ignore')

			if self.show_progress:
				progress.update(95, line1=utilities.getString(1445), line2=title, line3='%i %s' % (epCount, utilities.getString(1447)))

			s = self.traktFormatShow(show)
			if self.simulate:
				Debug("[Episodes Sync] %s" % str(s))
			else:
				self.traktapi.removeEpisode(s)
开发者ID:chx0003,项目名称:script.trakt,代码行数:27,代码来源:sync.py

示例6: traktRemoveMovies

	def traktRemoveMovies(self, movies):
		if len(movies) == 0:
			self.updateProgress(98, line2=utilities.getString(1474))
			Debug("[Movies Sync] trakt.tv movie collection is clean, no movies to remove.")
			return
		
		titles = ", ".join(["%s (%s)" % (m['title'], m['imdb_id']) for m in movies])
		Debug("[Movies Sync] %i movie(s) will be removed from trakt.tv collection." % len(movies))
		Debug("[Movies Sync] Movies removed: %s" % titles)

		self.updateProgress(80, line2="%i %s" % (len(movies), utilities.getString(1444)))
		
		chunked_movies = utilities.chunks([self.sanitizeMovieData(movie) for movie in movies], 50)
		i = 0
		x = float(len(chunked_movies))
		for chunk in chunked_movies:
			if self.isCanceled():
				return
			params = {'movies': chunk}
			if self.simulate:
				Debug("[Movies Sync] %s" % str(params))
			else:
				self.traktapi.removeMovie(params)

			i = i + 1
			y = ((i / x) * 20) + 80
			self.updateProgress(int(y), line2=utilities.getString(1476))

		self.updateProgress(98, line2=utilities.getString(1475) % len(movies))
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:29,代码来源:sync.py

示例7: traktUpdateEpisodes

	def traktUpdateEpisodes(self, shows):
		if len(shows) == 0:
			self.updateProgress(64, line1=utilities.getString(1438), line2=utilities.getString(1492))
			Debug("[Episodes Sync] trakt.tv episode playcounts are up to date.")
			return

		Debug("[Episodes Sync] %i show(s) are missing playcounts on trakt.tv" % len(shows))
		for show in shows:
			Debug("[Episodes Sync] Episodes updated: %s" % self.getShowAsString(show, short=True))

		self.updateProgress(46, line1=utilities.getString(1438), line2="%i %s" % (len(shows), utilities.getString(1439)), line3=" ")

		i = 0
		x = float(len(shows))
		for show in shows:
			if self.isCanceled():
				return

			epCount = self.countEpisodes([show])
			title = show['title'].encode('utf-8', 'ignore')

			i = i + 1
			y = ((i / x) * 18) + 46
			self.updateProgress(70, line2=title, line3="%i %s" % (epCount, utilities.getString(1440)))

			s = self.traktFormatShow(show)
			if self.simulate:
				Debug("[Episodes Sync] %s" % str(s))
			else:
				self.traktapi.updateSeenEpisode(s)

		self.updateProgress(64, line2="%i %s" % (len(shows), utilities.getString(1439)))
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:32,代码来源:sync.py

示例8: xbmcUpdateMovies

	def xbmcUpdateMovies(self, movies):
		if len(movies) == 0:
			self.updateProgress(80, line2=utilities.getString(1471))
			Debug("[Movies Sync] XBMC movie playcount is up to date.")
			return
		
		titles = ", ".join(["%s (%s)" % (m['title'], m['imdb_id']) for m in movies])
		Debug("[Movies Sync] %i movie(s) playcount will be updated in XBMC" % len(movies))
		Debug("[Movies Sync] Movies updated: %s" % titles)

		self.updateProgress(60, line2="%i %s" % (len(movies), utilities.getString(1430)))

		#split movie list into chunks of 50
		chunked_movies = utilities.chunks([{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": movies[i]['movieid'], "playcount": movies[i]['plays']}, "id": i} for i in range(len(movies))], 50)
		i = 0
		x = float(len(chunked_movies))
		for chunk in chunked_movies:
			if self.isCanceled():
				return
			if self.simulate:
				Debug("[Movies Sync] %s" % str(chunk))
			else:
				utilities.xbmcJsonRequest(chunk)

			i = i + 1
			y = ((i / x) * 20) + 60
			self.updateProgress(int(y), line2=utilities.getString(1472))

		self.updateProgress(80, line2=utilities.getString(1473) % len(movies))
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:29,代码来源:sync.py

示例9: __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
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:27,代码来源:sync.py

示例10: __addMoviesToTraktCollection

	def __addMoviesToTraktCollection(self, kodiMovies, traktMovies):
		if utilities.getSettingAsBool('add_movies_to_trakt') and not self.__isCanceled():
			addTraktMovies = copy.deepcopy(traktMovies)
			addKodiMovies = copy.deepcopy(kodiMovies)

			traktMoviesToAdd = self.__compareMovies(addKodiMovies, addTraktMovies)
			self.sanitizeMovies(traktMoviesToAdd)
			logger.debug("[Movies Sync] Compared movies, found %s to add." % len(traktMoviesToAdd))

			if len(traktMoviesToAdd) == 0:
				self.__updateProgress(48, line2=utilities.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.__updateProgress(37, line2=utilities.getString(32063) % len(traktMoviesToAdd))

			moviesToAdd = {'movies': traktMoviesToAdd}
			#logger.debug("Movies to add: %s" % moviesToAdd)
			try:
				self.traktapi.addToCollection(moviesToAdd)
			except Exception as ex:
				message = utilities.createError(ex)
				logging.fatal(message)

			self.__updateProgress(48, line2=utilities.getString(32085) % len(traktMoviesToAdd))
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:29,代码来源:sync.py

示例11: __rateOnTrakt

def __rateOnTrakt(rating, media_type, media, unrate=False):
    logger.debug("Sending rating (%s) to Trakt.tv" % rating)

    params = media
    if utils.isMovie(media_type):
        key = 'movies'
        params['rating'] = rating
    elif utils.isShow(media_type):
        key = 'shows'
        params['rating'] = rating
    elif utils.isSeason(media_type):
        key = 'shows'
        params['seasons'] = [{'rating': rating, 'number': media['season']}]
    elif utils.isEpisode(media_type):
        key = 'episodes'
        params['rating'] = rating
    else:
        return
    root = {key: [params]}

    if not unrate:
        data = globals.traktapi.addRating(root)
    else:
        data = globals.traktapi.removeRating(root)

    if data:
        s = utils.getFormattedItemName(media_type, media)
        if 'not_found' in data and not data['not_found']['movies'] and not data['not_found']['episodes'] and not data['not_found']['shows']:

            if not unrate:
                utils.notification(utils.getString(32040), s)
            else:
                utils.notification(utils.getString(32042), s)
        else:
            utils.notification(utils.getString(32044), s)
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:35,代码来源:rating.py

示例12: __addMovieProgressToKodi

	def __addMovieProgressToKodi(self, traktMovies, kodiMovies):

		if utilities.getSettingAsBool('trakt_movie_playback') and traktMovies and not self.__isCanceled():
			updateKodiTraktMovies = copy.deepcopy(traktMovies)
			updateKodiKodiMovies = copy.deepcopy(kodiMovies)

			kodiMoviesToUpdate = self.__compareMovies(updateKodiTraktMovies['movies'], updateKodiKodiMovies, restrict=True, playback=True)
			if len(kodiMoviesToUpdate) == 0:
				self.__updateProgress(99, line2=utilities.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.__updateProgress(85, line2=utilities.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']}}} 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) * 14) + 85
				self.__updateProgress(int(y), line2=utilities.getString(32127) % ((i)*chunksize if (i)*chunksize < x else x, x))
				utilities.kodiJsonRequest(chunk)

			self.__updateProgress(99, line2=utilities.getString(32128) % len(kodiMoviesToUpdate))
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:30,代码来源:sync.py

示例13: __traktLoadShowsPlaybackProgress

	def __traktLoadShowsPlaybackProgress(self):
		if utilities.getSettingAsBool('trakt_episode_playback') and not self.__isCanceled():
			self.__updateProgress(10, line1=utilities.getString(1485), line2=utilities.getString(32119))

			logger.debug('[Playback Sync] Getting playback progress from Trakt.tv')
			try:
				traktProgressShows = self.traktapi.getEpisodePlaybackProgress()
			except Exception:
				logger.debug("[Playback Sync] Invalid Trakt.tv progress list, possible error getting data from Trakt, aborting Trakt.tv playback update.")
				return False

			i = 0
			x = float(len(traktProgressShows))
			showsProgress = {'shows': []}
			for show in traktProgressShows:
				i += 1
				y = ((i / x) * 20) + 6
				self.__updateProgress(int(y), line2=utilities.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.__updateProgress(32, line2=utilities.getString(32121))

			return showsProgress
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:27,代码来源:sync.py

示例14: __deleteEpisodesFromTraktCollection

	def __deleteEpisodesFromTraktCollection(self, traktShows, kodiShows):
		if utilities.getSettingAsBool('clean_trakt_episodes') and not self.__isCanceled():
			removeTraktShows = copy.deepcopy(traktShows)
			removeKodiShows = copy.deepcopy(kodiShows)

			traktShowsRemove = self.__compareShows(removeTraktShows, removeKodiShows)
			self.sanitizeShows(traktShowsRemove)

			if len(traktShowsRemove['shows']) == 0:
				self.__updateProgress(65, line1=utilities.getString(32077), line2=utilities.getString(32110))
				logger.debug('[Episodes Sync] Trakt.tv episode collection is clean, no episodes to remove.')
				return

			logger.debug("[Episodes Sync] %i show(s) will have episodes removed from Trakt.tv collection." % len(traktShowsRemove['shows']))
			for show in traktShowsRemove['shows']:
				logger.debug("[Episodes Sync] Episodes removed: %s" % self.__getShowAsString(show, short=True))

			self.__updateProgress(50, line1=utilities.getString(32077), line2=utilities.getString(32111) % self.__countEpisodes(traktShowsRemove), line3=" ")

			logger.debug("[traktRemoveEpisodes] Shows to remove %s" % traktShowsRemove)
			try:
				self.traktapi.removeFromCollection(traktShowsRemove)
			except Exception as ex:
				message = utilities.createError(ex)
				logging.fatal(message)

			self.__updateProgress(65, line2=utilities.getString(32112) % self.__countEpisodes(traktShowsRemove), line3=" ")
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:27,代码来源:sync.py

示例15: rateOnTrakt

def rateOnTrakt(rating, media_type, media):
	Debug("[Rating] Sending rating (%s) to trakt.tv" % rating)
	if utilities.isMovie(media_type):
		params = {}
		params['title'] = media['title']
		params['year'] = media['year']
		params['rating'] = rating
		params['tmdb_id'] = media['tmdb_id']
		params['imdb_id'] = media['imdb_id']

		data = globals.traktapi.rateMovie(params)

	elif utilities.isEpisode(media_type):
		params = {}
		params['title'] = media['show']['title']
		params['year'] = media['show']['year']
		params['season'] = media['episode']['season']
		params['episode'] = media['episode']['number']
		params['rating'] = rating
		params['tvdb_id'] = media['show']['tvdb_id']
		params['imdb_id'] = media['show']['imdb_id']

		data = globals.traktapi.rateEpisode(params)

	else:
		return

	if data != None:
		notification(utilities.getString(1201), utilities.getString(1167)) # Rating submitted successfully
开发者ID:chx0003,项目名称:script.trakt,代码行数:29,代码来源:rating.py


注:本文中的utilities.getString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。