• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utilities.isShow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onInit

    def onInit(self):
        lang = utils.getString
        mange_string = lang(32133) if utils.isMovie(self.media_type) else lang(32134)
        rate_string = lang(32137)
        if utils.isShow(self.media_type):
            rate_string = lang(32138)
        elif utils.isSeason(self.media_type):
            rate_string = lang(32149)
        elif utils.isEpisode(self.media_type):
            rate_string = lang(32139)

        actions = [mange_string, lang(32135), lang(32136), rate_string, lang(32140), lang(32141), lang(32142), lang(32143)]
        keys = ["itemlists", "removefromlist", "addtolist", "rate", "togglewatched", "managelists", "updatetags",
                "sync"]

        l = self.getControl(ACTION_LIST)
        for i in range(len(actions)):
            if keys[i] in self.buttons:
                l.addItem(self.newListItem(actions[i], id=keys[i]))

        h = ((len(self.buttons)) * 46) - 6
        l.setHeight(h)

        d = self.getControl(DIALOG_IMAGE)
        d.setHeight(h + 40)

        self.setFocus(l)
开发者ID:CatoV9,项目名称:script.trakt,代码行数:27,代码来源:traktContextMenu.py


示例2: onInit

	def onInit(self):
		lang = utils.getString
		mange_string = lang(2000) if utils.isMovie(self.media_type) else lang(2001)
		rate_string = lang(2030)
		if utils.isShow(self.media_type):
			rate_string = lang(2031)
		elif utils.isEpisode(self.media_type):
			rate_string = lang(2032)

		actions = [mange_string, lang(2010), lang(2020), rate_string, lang(2040), lang(2050), lang(2060), lang(2070)]
		keys = ["itemlists", "removefromlist", "addtolist", "rate", "togglewatched", "managelists", "updatetags", "sync"]

		l = self.getControl(ACTION_LIST)
		for i in range(len(actions)):
			if keys[i] in self.buttons:
				l.addItem(self.newListItem(actions[i], id=keys[i]))

		h = ((len(self.buttons)) * 46) - 6
		l.setHeight(h)

		d = self.getControl(DIALOG_IMAGE)
		d.setHeight(h + 40)

		offset = (316 - h) / 2

		d.setPosition(0, offset - 20)
		l.setPosition(20, offset)

		self.setFocus(l)
开发者ID:Mafarricos,项目名称:Mafarricos-modded-xbmc-addons,代码行数:29,代码来源:traktContextMenu.py


示例3: __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


示例4: doManualRating

    def doManualRating(self, data):
        action = data['action']
        media_type = data['media_type']
        summaryInfo = None

        if not utilities.isValidMediaType(media_type):
            logger.debug("doManualRating(): Invalid media type '%s' passed for manual %s." % (media_type, action))
            return

        if not data['action'] in ['rate', 'unrate']:
            logger.debug("doManualRating(): Unknown action passed.")
            return

        logger.debug("Getting data for manual %s of %s: video_id: |%s| dbid: |%s|" % (action, media_type, data.get('video_id'), data.get('dbid')))

        id_type = utilities.parseIdToTraktIds(str(data['video_id']), media_type)[1]

        if not id_type:
            logger.debug("doManualRating(): Unrecognized id_type: |%s|-|%s|." % (media_type, data['video_id']))
            return
            
        ids = globals.traktapi.getIdLookup(data['video_id'], id_type)
        
        if not ids:
            logger.debug("doManualRating(): No Results for: |%s|-|%s|." % (media_type, data['video_id']))
            return
            
        trakt_id = dict(ids[0].keys)['trakt']
        if utilities.isEpisode(media_type):
            summaryInfo = globals.traktapi.getEpisodeSummary(trakt_id, data['season'], data['episode'])
            userInfo = globals.traktapi.getEpisodeRatingForUser(trakt_id, data['season'], data['episode'], 'trakt')
        elif utilities.isSeason(media_type):
            summaryInfo = globals.traktapi.getShowSummary(trakt_id)
            userInfo = globals.traktapi.getSeasonRatingForUser(trakt_id, data['season'], 'trakt')
        elif utilities.isShow(media_type):
            summaryInfo = globals.traktapi.getShowSummary(trakt_id)
            userInfo = globals.traktapi.getShowRatingForUser(trakt_id, 'trakt')
        elif utilities.isMovie(media_type):
            summaryInfo = globals.traktapi.getMovieSummary(trakt_id)
            userInfo = globals.traktapi.getMovieRatingForUser(trakt_id, 'trakt')

        if summaryInfo is not None:
            summaryInfo = summaryInfo.to_dict()
            summaryInfo['user'] = {'ratings': userInfo}
            if utilities.isEpisode(media_type):
                summaryInfo['season'] = data['season']
                summaryInfo['number'] = data['episode']
            elif utilities.isSeason(media_type):
                summaryInfo['season'] = data['season']

            if action == 'rate':
                if not 'rating' in data:
                    rateMedia(media_type, [summaryInfo])
                else:
                    rateMedia(media_type, [summaryInfo], rating=data['rating'])
        else:
            logger.debug("doManualRating(): Summary info was empty, possible problem retrieving data from Trakt.tv")
开发者ID:beljim,项目名称:tknorris-beta-repo,代码行数:57,代码来源:service.py


示例5: doManualRating

	def doManualRating(self, data):

		action = data['action']
		media_type = data['media_type']
		summaryInfo = None

		if not utilities.isValidMediaType(media_type):
			utilities.Debug("doManualRating(): Invalid media type '%s' passed for manual %s." % (media_type, action))
			return

		if not data['action'] in ['rate', 'unrate']:
			utilities.Debug("doManualRating(): Unknown action passed.")
			return
			
		if 'dbid' in data:
			utilities.Debug("Getting data for manual %s of library '%s' with ID of '%s'" % (action, media_type, data['dbid']))
		elif 'remoteitd' in data:
			if 'season' in data:
				utilities.Debug("Getting data for manual %s of non-library '%s' S%02dE%02d, with ID of '%s'." % (action, media_type, data['season'], data['episode'], data['remoteid']))
			else:
				utilities.Debug("Getting data for manual %s of non-library '%s' with ID of '%s'" % (action, media_type, data['remoteid']))

		if utilities.isEpisode(media_type):
			summaryInfo = globals.traktapi.getEpisodeSummary(data['tvdb_id'], data['season'], data['episode'])
		elif utilities.isShow(media_type):
			summaryInfo = globals.traktapi.getShowSummary(data['imdbnumber'])
		elif utilities.isMovie(media_type):
			summaryInfo = globals.traktapi.getMovieSummary(data['imdbnumber'])
		
		if not summaryInfo is None:
			if utilities.isMovie(media_type) or utilities.isShow(media_type):
				summaryInfo['xbmc_id'] = data['dbid']

			if action == 'rate':
				if not 'rating' in data:
					rateMedia(media_type, summaryInfo)
				else:
					rateMedia(media_type, summaryInfo, rating=data['rating'])
			elif action == 'unrate':
				rateMedia(media_type, summaryInfo, unrate=True)
		else:
			utilities.Debug("doManualRating(): Summary info was empty, possible problem retrieving data from trakt.tv")
开发者ID:perern,项目名称:script.trakt,代码行数:42,代码来源:service.py


示例6: __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


示例7: 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


示例8: onFocus

	def onFocus(self, controlID):
		if controlID in self.focus_labels:
			s = utils.getString(self.focus_labels[controlID])
			if self.rerate:
				if self.media['rating'] == self.buttons[controlID] or self.media['rating_advanced'] == self.buttons[controlID]:
					if utils.isMovie(self.media_type):
						s = utils.getString(1325)
					elif utils.isShow(self.media_type):
						s = utils.getString(1326)
					elif utils.isEpisode(self.media_type):
						s = utils.getString(1327)
					else:
						pass
			
			self.getControl(10013).setLabel(s)
		else:
			self.getControl(10013).setLabel('')
开发者ID:Dpons039,项目名称:script.trakt,代码行数:17,代码来源:rating.py


示例9: onFocus

	def onFocus(self, controlID):
		if controlID in self.focus_labels:
			s = utils.getString(self.focus_labels[controlID])

			if self.rerate:
				if self.media['user']['ratings'] and self.media['user']['ratings']['rating'] == self.buttons[controlID]:
					if utils.isMovie(self.media_type):
						s = utils.getString(32037)
					elif utils.isShow(self.media_type):
						s = utils.getString(32038)
					elif utils.isEpisode(self.media_type):
						s = utils.getString(32039)
					else:
						pass

			self.getControl(10013).setLabel(s)
		else:
			self.getControl(10013).setLabel('')
开发者ID:Leinad4Mind,项目名称:script.trakt,代码行数:18,代码来源:rating.py


示例10: doManualRating

    def doManualRating(self, data):
        action = data['action']
        media_type = data['media_type']
        summaryInfo = None

        if not utilities.isValidMediaType(media_type):
            logger.debug("doManualRating(): Invalid media type '%s' passed for manual %s." % (media_type, action))
            return

        if not data['action'] in ['rate', 'unrate']:
            logger.debug("doManualRating(): Unknown action passed.")
            return

        logger.debug("Getting data for manual %s of %s: imdb: |%s| dbid: |%s|" % (action, media_type, data.get('remoteid'), data.get('dbid')))

        if utilities.isEpisode(media_type):
            summaryInfo = globals.traktapi.getEpisodeSummary(data['imdbnumber'], data['season'], data['episode'])
            userInfo = globals.traktapi.getEpisodeRatingForUser(data['imdbnumber'], data['season'], data['episode'], 'imdb')
        elif utilities.isSeason(media_type):
            summaryInfo = globals.traktapi.getShowSummary(data['imdbnumber'])
            userInfo = globals.traktapi.getSeasonRatingForUser(data['imdbnumber'], data['season'], 'imdb')
        elif utilities.isShow(media_type):
            summaryInfo = globals.traktapi.getShowSummary(data['imdbnumber'])
            userInfo = globals.traktapi.getShowRatingForUser(data['imdbnumber'], 'imdb')
        elif utilities.isMovie(media_type):
            summaryInfo = globals.traktapi.getMovieSummary(data['imdbnumber'])
            userInfo = globals.traktapi.getMovieRatingForUser(data['imdbnumber'])

        if summaryInfo is not None:
            summaryInfo = summaryInfo.to_dict()
            summaryInfo['user'] = {'ratings': userInfo}
            if utilities.isEpisode(media_type):
                summaryInfo['season'] = data['season']
                summaryInfo['number'] = data['episode']
            elif utilities.isSeason(media_type):
                summaryInfo['season'] = data['season']

            if action == 'rate':
                if not 'rating' in data:
                    rateMedia(media_type, [summaryInfo])
                else:
                    rateMedia(media_type, [summaryInfo], rating=data['rating'])
        else:
            logger.debug("doManualRating(): Summary info was empty, possible problem retrieving data from Trakt.tv")
开发者ID:TonyPh12345,项目名称:kodibrasilforum,代码行数:44,代码来源:service.py


示例11: onInit

    def onInit(self):
        mange_string = getString(32133) if isMovie(self.media_type) else getString(32134)
        rate_string = getString(32137)
        if isShow(self.media_type):
            rate_string = getString(32138)
        elif isSeason(self.media_type):
            rate_string = getString(32149)
        elif isEpisode(self.media_type):
            rate_string = getString(32139)

        actions = [mange_string, getString(32135), getString(32136), rate_string, getString(32140), getString(32141), getString(32142), getString(32143)]
        keys = ["itemlists", "removefromlist", "addtowatchlist", "rate", "togglewatched", "managelists", "updatetags",
                "sync"]

        l = self.getControl(ACTION_LIST)
        for i in range(len(actions)):
            if keys[i] in self.buttons:
                l.addItem(self.newListItem(actions[i], id=keys[i]))

        self.setFocus(l)
开发者ID:RottenKid,项目名称:script.trakt,代码行数:20,代码来源:traktContextMenu.py


示例12: __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


示例13: Main

def Main():
    args = __getArguments()
    data = {}

    if args['action'] == 'auth_info':
        data['action'] = 'auth_info'

    if args['action'] == 'contextmenu':
        buttons = []
        media_type = kodiUtilities.getMediaType()

        if media_type in ['movie', 'show', 'season', 'episode']:
            buttons.append("rate")
            buttons.append("togglewatched")
            buttons.append("addtowatchlist")

        buttons.append("sync")

        contextMenu = traktContextMenu(media_type=media_type, buttons=buttons)
        contextMenu.doModal()
        _action = contextMenu.action
        del contextMenu

        if _action is None:
            return

        logger.debug("'%s' selected from trakt.tv action menu" % _action)
        args['action'] = _action

    if args['action'] == 'sync':
        data = {'action': 'manualSync', 'silent': False}
        if 'silent' in args:
            data['silent'] = (args['silent'].lower() == 'true')
        data['library'] = "all"
        if 'library' in args and args['library'] in ['episodes', 'movies']:
            data['library'] = args['library']

    elif args['action'] in ['rate', 'unrate']:
        data = {'action': args['action']}
        media_type = None
        if 'media_type' in args and 'dbid' in args:
            media_type = args['media_type']
            try:
                data['dbid'] = int(args['dbid'])
            except ValueError:
                logger.debug("Manual %s triggered for library item, but DBID is invalid." % args['action'])
                return
        elif 'media_type' in args and 'remoteid' in args:
            media_type = args['media_type']
            data['remoteid'] = args['remoteid']
            try:
                data['season'] = int(args['season'])
                data['episode'] = int(args['episode'])
            except ValueError:
                logger.debug("Error parsing season or episode for manual %s" % args['action'])
                return
            except KeyError:
                pass
        else:
            media_type = kodiUtilities.getMediaType()
            if not utilities.isValidMediaType(media_type):
                logger.debug("Error, not in video library.")
                return
            data['dbid'] = int(xbmc.getInfoLabel('ListItem.DBID'))

        if media_type is None:
            logger.debug("Manual %s triggered on an unsupported content container." % args['action'])
        elif utilities.isValidMediaType(media_type):
            data['media_type'] = media_type
            if 'dbid' in data:
                logger.debug("Manual %s of library '%s' with an ID of '%s'." % (args['action'], media_type, data['dbid']))
                if utilities.isMovie(media_type):
                    result = kodiUtilities.getMovieDetailsFromKodi(data['dbid'], ['imdbnumber', 'title', 'year'])
                    if not result:
                        logger.debug("No data was returned from Kodi, aborting manual %s." % args['action'])
                        return

                elif utilities.isShow(media_type):
                    tvshow_id = data['dbid']

                elif utilities.isSeason(media_type):
                    result = kodiUtilities.getSeasonDetailsFromKodi(data['dbid'], ['tvshowid', 'season'])
                    if not result:
                        logger.debug("No data was returned from Kodi, aborting manual %s." % args['action'])
                        return
                    tvshow_id = result['tvshowid']
                    data['season'] = result['season']

                elif utilities.isEpisode(media_type):
                    result = kodiUtilities.getEpisodeDetailsFromKodi(data['dbid'], ['season', 'episode', 'tvshowid'])
                    if not result:
                        logger.debug("No data was returned from Kodi, aborting manual %s." % args['action'])
                        return
                    tvshow_id = result['tvshowid']
                    data['season'] = result['season']
                    data['episode'] = result['episode']

                if utilities.isShow(media_type) or utilities.isSeason(media_type) or utilities.isEpisode(media_type):
                    result = kodiUtilities.getShowDetailsFromKodi(tvshow_id, ['imdbnumber'])
                    if not result:
#.........这里部分代码省略.........
开发者ID:RottenKid,项目名称:script.trakt,代码行数:101,代码来源:script.py


示例14: 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


示例15: Main

def Main():

	args = getArguments()
	data = {}

	if args['action'] == 'sync':
		data = {'action': 'manualSync'}

	elif args['action'] in ['rate', 'unrate']:
		data = {}
		data['action'] = args['action']
		media_type = None
		if 'media_type' in args and 'dbid' in args:
			media_type = args['media_type']
			try:
				data['dbid'] = int(args['dbid'])
			except ValueError:
				utils.Debug("Manual %s triggered for library item, but DBID is invalid." % args['action'])
				return
		elif 'media_type' in args and 'remoteid' in args:
			media_type = args['media_type']
			data['remoteid'] = args['remoteid']
			if 'season' in args:
				if not 'episode' in args:
					utils.Debug("Manual %s triggered for non-library episode, but missing episode number." % args['action'])
					return
				try:
					data['season'] = int(args['season'])
					data['episode'] = int(args['episode'])
				except ValueError:
					utilities.Debug("Error parsing season or episode for manual %s" % args['action'])
					return
		else:
			media_type = getMediaType()
			if not utils.isValidMediaType(media_type):
				utils.Debug("Error, not in video library.")
				return
			data['dbid'] = int(xbmc.getInfoLabel('ListItem.DBID'))

		if media_type is None:
			utils.Debug("Manual %s triggered on an unsupported content container." % args['action'])
		elif utils.isValidMediaType(media_type):
			data['media_type'] = media_type
			if 'dbid' in data:
				utils.Debug("Manual %s of library '%s' with an ID of '%s'." % (args['action'], media_type, data['dbid']))
				if utils.isMovie(media_type):
					result = utils.getMovieDetailsFromXbmc(data['dbid'], ['imdbnumber', 'title', 'year'])
					if not result:
						utils.Debug("No data was returned from XBMC, aborting manual %s." % args['action'])
						return
					data['imdbnumber'] = result['imdbnumber']

				elif utils.isShow(media_type):
					result = utils.getShowDetailsFromXBMC(data['dbid'], ['imdbnumber', 'tag'])
					if not result:
						utils.Debug("No data was returned from XBMC, aborting manual %s." % args['action'])
						return
					data['imdbnumber'] = result['imdbnumber']
					data['tag'] = result['tag']

				elif utils.isEpisode(media_type):
					result = utils.getEpisodeDetailsFromXbmc(data['dbid'], ['showtitle', 'season', 'episode', 'tvshowid'])
					if not result:
						utils.Debug("No data was returned from XBMC, aborting manual %s." % args['action'])
						return
					data['tvdb_id'] = result['tvdb_id']
					data['season'] = result['season']
					data['episode'] = result['episode']

			else:
				if 'season' in data:
					utils.Debug("Manual %s of non-library '%s' S%02dE%02d, with an ID of '%s'." % (args['action'], media_type, data['season'], data['episode'], data['remoteid']))
					data['tvdb_id'] = data['remoteid']
				else:
					utils.Debug("Manual %s of non-library '%s' with an ID of '%s'." % (args['action'], media_type, data['remoteid']))
					data['imdbnumber'] = data['remoteid']

			if args['action'] == 'rate' and 'rating' in args:
				if args['rating'] in ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']:
					data['rating'] = int(args['rating'])

			data = {'action': 'manualRating', 'ratingData': data}

		else:
			utils.Debug("Manual %s of '%s' is unsupported." % (args['action'], media_type))

	elif args['action'] == 'togglewatched':
		media_type = getMediaType()
		if media_type in ['movie', 'show', 'season', 'episode']:
			data = {}
			data['media_type'] = media_type
			if utils.isMovie(media_type):
				dbid = int(xbmc.getInfoLabel('ListItem.DBID'))
				result = utils.getMovieDetailsFromXbmc(dbid, ['imdbnumber', 'title', 'year', 'playcount'])
				if result:
					if result['playcount'] == 0:
						data['id'] = result['imdbnumber']
					else:
						utils.Debug("Movie alread marked as watched in XBMC.")
				else:
#.........这里部分代码省略.........
开发者ID:foXaCe,项目名称:script.trakt,代码行数:101,代码来源:script.py


示例16: test_isShow

def test_isShow():
    assert utilities.isShow('show')
开发者ID:RottenKid,项目名称:script.trakt,代码行数:2,代码来源:test_utilities.py


示例17: Main

def Main():

    args = getArguments()
    data = {}

    if args["action"] == "contextmenu":
        buttons = []
        media_type = getMediaType()

        if utils.getSettingAsBool("tagging_enable"):
            if utils.isMovie(media_type):
                buttons.append("itemlists")
                dbid = int(xbmc.getInfoLabel("ListItem.DBID"))
                result = utils.getMovieDetailsFromXbmc(dbid, ["tag"])
                if tagging.hasTraktWatchlistTag(result["tag"]):
                    buttons.append("removefromlist")
                else:
                    buttons.append("addtolist")
            elif utils.isShow(media_type):
                buttons.append("itemlists")
                dbid = int(xbmc.getInfoLabel("ListItem.DBID"))
                result = utils.getShowDetailsFromXBMC(dbid, ["tag"])
                if tagging.hasTraktWatchlistTag(result["tag"]):
                    buttons.append("removefromlist")
                else:
                    buttons.append("addtolist")

        if media_type in ["movie", "show", "episode"]:
            buttons.append("rate")

        if media_type in ["movie", "show", "season", "episode"]:
            buttons.append("togglewatched")

        if utils.getSettingAsBool("tagging_enable"):
            buttons.append("managelists")
            buttons.append("updatetags")
        buttons.append("sync")

        contextMenu = traktContextMenu(media_type=media_type, buttons=buttons)
        contextMenu.doModal()
        _action = contextMenu.action
        del contextMenu

        if _action is None:
            return

        utils.Debug("'%s' selected from trakt.tv action menu" % _action)
        args["action"] = _action
        if _action in ["addtolist", "removefromlist"]:
            args["list"] = "watchlist"

    if args["action"] == "sync":
        data = {"action": "manualSync"}
        data["silent"] = False
        if "silent" in args:
            data["silent"] = args["silent"].lower() == "true"

    elif args["action"] == "loadsettings":
        data = {"action": "loadsettings", "force": True}
        utils.notification(utils.getString(1201), utils.getString(1111))

    elif args["action"] in ["rate", "unrate"]:
        data = {}
        data["action"] = args["action"]
        media_type = None
        if "media_type" in args and "dbid" in args:
            media_type = args["media_type"]
            try:
                data["dbid"] = int(args["dbid"])
            except ValueError:
                utils.Debug("Manual %s triggered for library item, but DBID is invalid." % args["action"])
                return
        elif "media_type" in args and "remoteid" in args:
            media_type = args["media_type"]
            data["remoteid"] = args["remoteid"]
            if "season" in args:
                if not "episode" in args:
                    utils.Debug(
                        "Manual %s triggered for non-library episode, but missing episode number." % args["action"]
                    )
                    return
                try:
                    data["season"] = int(args["season"])
                    data["episode"] = int(args["episode"])
                except ValueError:
                    utilities.Debug("Error parsing season or episode for manual %s" % args["action"])
                    return
        else:
            media_type = getMediaType()
            if not utils.isValidMediaType(media_type):
                utils.Debug("Error, not in video library.")
                return
            data["dbid"] = int(xbmc.getInfoLabel("ListItem.DBID"))

        if media_type is None:
            utils.Debug("Manual %s triggered on an unsupported content container." % args["action"])
        elif utils.isValidMediaType(media_type):
            data["media_type"] = media_type
            if "dbid" in data:
                utils.Debug(
#.........这里部分代码省略.........
开发者ID:perern,项目名称:script.trakt,代码行数:101,代码来源:script.py


示例18: 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


示例19: Main

def Main():
    args = __getArguments()
    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utilities.is_wrapped_object函数代码示例发布时间:2022-05-26
下一篇:
Python utilities.isMovie函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap