本文整理汇总了Python中utilities.getFormattedItemName函数的典型用法代码示例。如果您正苦于以下问题:Python getFormattedItemName函数的具体用法?Python getFormattedItemName怎么用?Python getFormattedItemName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getFormattedItemName函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __scrobbleNotification
def __scrobbleNotification(self, info):
if not self.curVideoInfo:
return
if utilities.getSettingAsBool("scrobble_notification"):
s = utilities.getFormattedItemName(self.curVideo["type"], info[self.curVideo["type"]])
utilities.notification(utilities.getString(32015), s)
开发者ID:rickardrocks,项目名称:tknorris-beta-repo,代码行数:7,代码来源:scrobbler.py
示例2: __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
示例3: scrobbleNotification
def scrobbleNotification(self, info):
if not self.curVideoInfo:
return
if utilities.getSettingAsBool("scrobble_notification"):
s = utilities.getFormattedItemName(self.curVideo['type'], info)
utilities.notification(utilities.getString(1049), s)
开发者ID:Mesoptier,项目名称:script.trakt,代码行数:7,代码来源:scrobbler.py
示例4: onInit
def onInit(self):
s = utils.getFormattedItemName(self.media_type, self.media)
self.getControl(10012).setLabel(s)
rateID = 11029 + self.default_rating
if self.rerate and self.media['user']['ratings'] and int(self.media['user']['ratings']['rating']) > 0:
rateID = 11029 + int(self.media['user']['ratings']['rating'])
self.setFocus(self.getControl(rateID))
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:8,代码来源:rating.py
示例5: __rateOnTrakt
def __rateOnTrakt(rating, media_type, media, unrate=False):
logger.debug("Sending rating (%s) to Trakt.tv" % rating)
params = {}
if utils.isMovie(media_type):
params = media
params['rating'] = rating
root = {}
listing = [params]
root['movies'] = listing
elif utils.isShow(media_type):
params['rating'] = rating
params['title'] = media['title']
params['year'] = media['year']
params['ids'] = {}
params['ids']['tmdb'] = media['ids']['tmdb']
params['ids']['imdb'] = media['ids']['imdb']
params['ids']['tvdb'] = media['ids']['tvdb']
root = {}
listing = [params]
root['shows'] = listing
elif utils.isEpisode(media_type):
params = media
params['rating'] = rating
root = {}
listing = [params]
root['episodes'] = listing
else:
return
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:Leinad4Mind,项目名称:script.trakt,代码行数:51,代码来源:rating.py
示例6: rateOnTrakt
def rateOnTrakt(rating, media_type, media, unrate=False):
utils.Debug("[Rating] Sending rating (%s) to trakt.tv" % rating)
params = {}
params["rating"] = rating
if utils.isMovie(media_type):
params["title"] = media["title"]
params["year"] = media["year"]
params["tmdb_id"] = media["tmdb_id"]
params["imdb_id"] = media["imdb_id"]
data = globals.traktapi.rateMovie(params)
elif utils.isShow(media_type):
params["title"] = media["title"]
params["year"] = media["year"]
params["tvdb_id"] = media["tvdb_id"]
params["imdb_id"] = media["imdb_id"]
data = globals.traktapi.rateShow(params)
elif utils.isEpisode(media_type):
params["title"] = media["show"]["title"]
params["year"] = media["show"]["year"]
params["season"] = media["episode"]["season"]
params["episode"] = media["episode"]["number"]
params["tvdb_id"] = media["show"]["tvdb_id"]
params["imdb_id"] = media["show"]["imdb_id"]
data = globals.traktapi.rateEpisode(params)
else:
return
if data:
s = utils.getFormattedItemName(media_type, media)
if "status" in data and data["status"] == "success":
if not unrate:
utils.notification(utils.getString(1350), s)
else:
utils.notification(utils.getString(1352), s)
elif "status" in data and data["status"] == "failure":
utils.notification(utils.getString(1354), s)
else:
# status not in data, different problem, do nothing for now
pass
开发者ID:hephaistosthemaker,项目名称:script.trakt,代码行数:47,代码来源:rating.py
示例7: onInit
def onInit(self):
self.getControl(10014).setVisible(self.rating_type == 'simple')
self.getControl(10015).setVisible(self.rating_type == 'advanced')
s = utils.getFormattedItemName(self.media_type, self.media, short=True)
self.getControl(10012).setLabel(s)
rateID = None
if self.rating_type == 'simple':
rateID = 10030
if self.rerate:
if self.media['rating'] == "hate":
rateID = 10031
else:
rateID = 11037
if self.rerate and int(self.media['rating_advanced']) > 0:
rateID = 11029 + int(self.media['rating_advanced'])
self.setFocus(self.getControl(rateID))
开发者ID:Dpons039,项目名称:script.trakt,代码行数:18,代码来源:rating.py
示例8: __rateOnTrakt
def __rateOnTrakt(rating, media_type, media, unrate=False):
logger.debug("Sending rating (%s) to Trakt.tv" % rating)
params = media
if utilities.isMovie(media_type):
key = 'movies'
params['rating'] = rating
if 'movieid' in media:
kodiUtilities.kodiJsonRequest({"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": media['movieid'], "userrating": rating}})
elif utilities.isShow(media_type):
key = 'shows'
params['rating'] = rating
if 'tvshowid' in media:
kodiUtilities.kodiJsonRequest({"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.SetTVShowDetails", "params": {"tvshowid": media['tvshowid'], "userrating": rating}})
elif utilities.isSeason(media_type):
key = 'shows'
params['seasons'] = [{'rating': rating, 'number': media['season']}]
elif utilities.isEpisode(media_type):
key = 'episodes'
params['rating'] = rating
if 'episodeid' in media:
kodiUtilities.kodiJsonRequest({"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.SetEpisodeDetails", "params": {"episodeid": media['episodeid'], "userrating": rating}})
else:
return
root = {key: [params]}
if not unrate:
data = globals.traktapi.addRating(root)
else:
data = globals.traktapi.removeRating(root)
if data:
s = utilities.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:
kodiUtilities.notification(kodiUtilities.getString(32040), s)
else:
kodiUtilities.notification(kodiUtilities.getString(32042), s)
else:
kodiUtilities.notification(kodiUtilities.getString(32044), s)
开发者ID:RottenKid,项目名称:script.trakt,代码行数:41,代码来源:rating.py
示例9: watchlistTagCheck
def watchlistTagCheck(self):
if not utilities.isMovie(self.curVideo['type']):
return
if not 'id' in self.curVideo:
return
if not (tagging.isTaggingEnabled() and tagging.isWatchlistsEnabled()):
return
id = self.curVideo['id']
result = utilities.getMovieDetailsFromXbmc(id, ['tag'])
if result:
tags = result['tag']
if tagging.hasTraktWatchlistTag(tags):
tags.remove(tagging.listToTag("Watchlist"))
s = utilities.getFormattedItemName(self.curVideo['type'], self.curVideoInfo)
tagging.xbmcSetTags(id, self.curVideo['type'], s, tags)
else:
utilities.Debug("No data was returned from XBMC, aborting tag udpate.")
开发者ID:Mesoptier,项目名称:script.trakt,代码行数:23,代码来源:scrobbler.py
示例10: test_getFormattedItemName_Movie
def test_getFormattedItemName_Movie():
data = load_params_from_json('tests/fixtures/movie.json')
assert utilities.getFormattedItemName('movie', data) == b'TRON: Legacy (2010)'
开发者ID:RottenKid,项目名称:script.trakt,代码行数:3,代码来源:test_utilities.py
示例11: rateMedia
def rateMedia(media_type, itemsToRate, unrate=False, rating=None):
"""Launches the rating dialog"""
for summary_info in itemsToRate:
if not utils.isValidMediaType(media_type):
logger.debug("Not a valid media type")
return
elif 'user' not in summary_info:
logger.debug("No user data")
return
s = utils.getFormattedItemName(media_type, summary_info)
logger.debug("Summary Info %s" % summary_info)
if unrate:
rating = None
if summary_info['user']['ratings']['rating'] > 0:
rating = 0
if not rating is None:
logger.debug("'%s' is being unrated." % s)
__rateOnTrakt(rating, media_type, summary_info, unrate=True)
else:
logger.debug("'%s' has not been rated, so not unrating." % s)
return
rerate = utils.getSettingAsBool('rate_rerate')
if rating is not None:
if summary_info['user']['ratings']['rating'] == 0:
logger.debug("Rating for '%s' is being set to '%d' manually." % (s, rating))
__rateOnTrakt(rating, media_type, summary_info)
else:
if rerate:
if not summary_info['user']['ratings']['rating'] == rating:
logger.debug("Rating for '%s' is being set to '%d' manually." % (s, rating))
__rateOnTrakt(rating, media_type, summary_info)
else:
utils.notification(utils.getString(32043), s)
logger.debug("'%s' already has a rating of '%d'." % (s, rating))
else:
utils.notification(utils.getString(32041), s)
logger.debug("'%s' is already rated." % s)
return
if summary_info['user']['ratings'] and summary_info['user']['ratings']['rating']:
if not rerate:
logger.debug("'%s' has already been rated." % s)
utils.notification(utils.getString(32041), s)
return
else:
logger.debug("'%s' is being re-rated." % s)
xbmc.executebuiltin('Dialog.Close(all, true)')
gui = RatingDialog(
"script-trakt-RatingDialog.xml",
__addon__.getAddonInfo('path'),
media_type=media_type,
media=summary_info,
rerate=rerate
)
gui.doModal()
if gui.rating:
rating = gui.rating
if rerate:
rating = gui.rating
if summary_info['user']['ratings'] and summary_info['user']['ratings']['rating'] > 0 and rating == summary_info['user']['ratings']['rating']:
rating = 0
if rating == 0 or rating == "unrate":
__rateOnTrakt(rating, gui.media_type, gui.media, unrate=True)
else:
__rateOnTrakt(rating, gui.media_type, gui.media)
else:
logger.debug("Rating dialog was closed with no rating.")
del gui
#Reset rating and unrate for multi part episodes
unrate=False
rating=None
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:84,代码来源:rating.py
示例12: doMarkWatched
def doMarkWatched(self, data):
media_type = data['media_type']
simulate = utilities.getSettingAsBool('simulate_sync')
markedNotification = utilities.getSettingAsBool('show_marked_notification')
if utilities.isMovie(media_type):
summaryInfo = globals.traktapi.getMovieSummary(data['id'])
if summaryInfo:
if not summaryInfo['watched']:
s = utilities.getFormattedItemName(media_type, summaryInfo)
utilities.Debug("doMarkWatched(): '%s' is not watched on trakt, marking it as watched." % s)
movie = {}
movie['imdb_id'] = data['id']
movie['title'] = summaryInfo['title']
movie['year'] = summaryInfo['year']
movie['plays'] = 1
movie['last_played'] = int(time())
params = {'movies': [movie]}
utilities.Debug("doMarkWatched(): %s" % str(params))
if not simulate:
result = globals.traktapi.updateSeenMovie(params)
if result:
if markedNotification:
utilities.notification(utilities.getString(1550), s)
else:
utilities.notification(utilities.getString(1551), s)
else:
if markedNotification:
utilities.notification(utilities.getString(1550), s)
elif utilities.isEpisode(media_type):
summaryInfo = globals.traktapi.getEpisodeSummary(data['id'], data['season'], data['episode'])
if summaryInfo:
if not summaryInfo['episode']['watched']:
s = utilities.getFormattedItemName(media_type, summaryInfo)
utilities.Debug("doMarkWathced(): '%s' is not watched on trakt, marking it as watched." % s)
params = {}
params['imdb_id'] = summaryInfo['show']['imdb_id']
params['tvdb_id'] = summaryInfo['show']['tvdb_id']
params['title'] = summaryInfo['show']['title']
params['year'] = summaryInfo['show']['year']
params['episodes'] = [{'season': data['season'], 'episode': data['episode']}]
utilities.Debug("doMarkWatched(): %s" % str(params))
if not simulate:
result = globals.traktapi.updateSeenEpisode(params)
if result:
if markedNotification:
utilities.notification(utilities.getString(1550), s)
else:
utilities.notification(utilities.getString(1551), s)
else:
if markedNotification:
utilities.notification(utilities.getString(1550), s)
elif utilities.isSeason(media_type):
showInfo = globals.traktapi.getShowSummary(data['id'])
if not showInfo:
return
summaryInfo = globals.traktapi.getSeasonInfo(data['id'], data['season'])
if summaryInfo:
showInfo['season'] = data['season']
s = utilities.getFormattedItemName(media_type, showInfo)
params = {}
params['imdb_id'] = showInfo['imdb_id']
params['tvdb_id'] = showInfo['tvdb_id']
params['title'] = showInfo['title']
params['year'] = showInfo['year']
params['episodes'] = []
for ep in summaryInfo:
if ep['episode'] in data['episodes']:
if not ep['watched']:
params['episodes'].append({'season': ep['season'], 'episode': ep['episode']})
utilities.Debug("doMarkWatched(): '%s - Season %d' has %d episode(s) that are going to be marked as watched." % (showInfo['title'], data['season'], len(params['episodes'])))
if len(params['episodes']) > 0:
utilities.Debug("doMarkWatched(): %s" % str(params))
if not simulate:
result = globals.traktapi.updateSeenEpisode(params)
if result:
if markedNotification:
utilities.notification(utilities.getString(1550), utilities.getString(1552) % (len(params['episodes']), s))
else:
utilities.notification(utilities.getString(1551), utilities.getString(1552) % (len(params['episodes']), s))
else:
if markedNotification:
utilities.notification(utilities.getString(1550), utilities.getString(1552) % (len(params['episodes']), s))
elif utilities.isShow(media_type):
summaryInfo = globals.traktapi.getShowSummary(data['id'], extended=True)
if summaryInfo:
s = utilities.getFormattedItemName(media_type, summaryInfo)
params = {}
params['imdb_id'] = summaryInfo['imdb_id']
params['tvdb_id'] = summaryInfo['tvdb_id']
params['title'] = summaryInfo['title']
params['year'] = summaryInfo['year']
#.........这里部分代码省略.........
开发者ID:perern,项目名称:script.trakt,代码行数:101,代码来源:service.py
示例13: rateMedia
def rateMedia(media_type, summary_info, unrate=False, rating=None):
"""Launches the rating dialog"""
if not utils.isValidMediaType(media_type):
return
if utils.isEpisode(media_type):
if 'rating' in summary_info['episode']:
summary_info['rating'] = summary_info['episode']['rating']
if 'rating_advanced' in summary_info['episode']:
summary_info['rating_advanced'] = summary_info['episode']['rating_advanced']
s = utils.getFormattedItemName(media_type, summary_info)
if not globals.traktapi.settings:
globals.traktapi.getAccountSettings()
rating_type = globals.traktapi.settings['viewing']['ratings']['mode']
if unrate:
rating = None
if rating_type == "simple":
if not summary_info['rating'] == "false":
rating = "unrate"
else:
if summary_info['rating_advanced'] > 0:
rating = 0
if not rating is None:
utils.Debug("[Rating] '%s' is being unrated." % s)
rateOnTrakt(rating, media_type, summary_info, unrate=True)
else:
utils.Debug("[Rating] '%s' has not been rated, so not unrating." % s)
return
rerate = utils.getSettingAsBool('rate_rerate')
if not rating is None:
if summary_info['rating_advanced'] == 0:
utils.Debug("[Rating] Rating for '%s' is being set to '%d' manually." % (s, rating))
rateOnTrakt(rating, media_type, summary_info)
else:
if rerate:
if not summary_info['rating_advanced'] == rating:
utils.Debug("[Rating] Rating for '%s' is being set to '%d' manually." % (s, rating))
rateOnTrakt(rating, media_type, summary_info)
else:
utils.notification(utils.getString(1353), s)
utils.Debug("[Rating] '%s' already has a rating of '%d'." % (s, rating))
else:
utils.notification(utils.getString(1351), s)
utils.Debug("[Rating] '%s' is already rated." % s)
return
if summary_info['rating'] or summary_info['rating_advanced']:
if not rerate:
utils.Debug("[Rating] '%s' has already been rated." % s)
utils.notification(utils.getString(1351), s)
return
else:
utils.Debug("[Rating] '%s' is being re-rated." % s)
xbmc.executebuiltin('Dialog.Close(all, true)')
gui = RatingDialog(
"RatingDialog.xml",
__addon__.getAddonInfo('path'),
media_type=media_type,
media=summary_info,
rating_type=rating_type,
rerate=rerate
)
gui.doModal()
if gui.rating:
rating = gui.rating
if rerate:
rating = gui.rating
if rating_type == "simple":
if not summary_info['rating'] == "false" and rating == summary_info['rating']:
rating = "unrate"
else:
if summary_info['rating_advanced'] > 0 and rating == summary_info['rating_advanced']:
rating = 0
if rating == 0 or rating == "unrate":
rateOnTrakt(rating, gui.media_type, gui.media, unrate=True)
else:
rateOnTrakt(rating, gui.media_type, gui.media)
else:
utils.Debug("[Rating] Rating dialog was closed with no rating.")
del gui
开发者ID:Dpons039,项目名称:script.trakt,代码行数:93,代码来源:rating.py
示例14: rateOnTrakt
def rateOnTrakt(rating, media_type, media, unrate=False):
utils.Debug("[Rating] Sending rating (%s) to trakt.tv" % rating)
params = {}
params['rating'] = rating
if utils.isMovie(media_type):
params['title'] = media['title']
params['year'] = media['year']
params['tmdb_id'] = media['tmdb_id']
params['imdb_id'] = media['imdb_id']
data = globals.traktapi.rateMovie(params)
elif utils.isShow(media_type):
params['title'] = media['title']
params['year'] = media['year']
params['tvdb_id'] = media['tvdb_id']
params['imdb_id'] = media['imdb_id']
data = globals.traktapi.rateShow(params)
elif utils.isEpisode(media_type):
params['title'] = media['show']['title']
params['year'] = media['show']['year']
params['season'] = media['episode']['season']
params['episode'] = media['episode']['number']
params['tvdb_id'] = media['show']['tvdb_id']
params['imdb_id'] = media['show']['imdb_id']
data = globals.traktapi.rateEpisode(params)
else:
return
if data:
s = utils.getFormattedItemName(media_type, media)
if 'status' in data and data['status'] == "success":
if tagging.isTaggingEnabled() and tagging.isRatingsEnabled():
if utils.isMovie(media_type) or utils.isShow(media_type):
id = media['xbmc_id']
f = utils.getMovieDetailsFromXbmc if utils.isMovie(media_type) else utils.getShowDetailsFromXBMC
result = f(id, ['tag'])
if result:
tags = result['tag']
new_rating = rating
if new_rating == "love":
new_rating = 10
elif new_rating == "hate":
new_rating = 1
new_rating_tag = tagging.ratingToTag(new_rating)
if unrate:
new_rating_tag = ""
update = False
if tagging.hasTraktRatingTag(tags):
old_rating_tag = tagging.getTraktRatingTag(tags)
if not old_rating_tag == new_rating_tag:
tags.remove(old_rating_tag)
update = True
if not unrate and new_rating >= tagging.getMinRating():
tags.append(new_rating_tag)
update = True
if update:
tagging.xbmcSetTags(id, media_type, s, tags)
else:
utils.Debug("No data was returned from XBMC, aborting tag udpate.")
if not unrate:
utils.notification(utils.getString(1350), s)
else:
utils.notification(utils.getString(1352), s)
elif 'status' in data and data['status'] == "failure":
utils.notification(utils.getString(1354), s)
else:
# status not in data, different problem, do nothing for now
pass
开发者ID:Dpons039,项目名称:script.trakt,代码行数:85,代码来源:rating.py
示例15: test_getFormattedItemName_Show
def test_getFormattedItemName_Show():
data = load_params_from_json('tests/fixtures/show.json')
assert utilities.getFormattedItemName('show', data) == b'Game of Thrones'
开发者ID:RottenKid,项目名称:script.trakt,代码行数:3,代码来源:test_utilities.py
示例16: test_getFormattedItemName_Episode
def test_getFormattedItemName_Episode():
data = load_params_from_json('tests/fixtures/episode.json')
assert utilities.getFormattedItemName('episode', data) == b'S01E01 - Winter Is Coming'
开发者ID:RottenKid,项目名称:script.trakt,代码行数:3,代码来源:test_utilities.py
示例17: test_getFormattedItemName_Season
def test_getFormattedItemName_Season():
data = load_params_from_json('tests/fixtures/season.json')
assert utilities.getFormattedItemName('season', data) == b'Winter Is Coming - Season 1'
开发者ID:RottenKid,项目名称:script.trakt,代码行数:3,代码来源:test_utilities.py
注:本文中的utilities.getFormattedItemName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论