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


Python Request.getJson方法代码示例

本文整理汇总了Python中request.Request.getJson方法的典型用法代码示例。如果您正苦于以下问题:Python Request.getJson方法的具体用法?Python Request.getJson怎么用?Python Request.getJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在request.Request的用法示例。


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

示例1: chooseGameVideoMenu

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import getJson [as 别名]
def chooseGameVideoMenu():
    video_id = vars.params.get("video_id")
    video_type = vars.params.get("video_type")
    seo_name = vars.params.get("seo_name")
    has_away_feed = vars.params.get("has_away_feed", "0") == "1"
    has_condensed_game = vars.params.get("has_condensed_game", "0") == "1"
    start_time = vars.params.get("start_time")
    duration = vars.params.get("duration")
    game_data_json = Request.getJson(vars.config['game_data_endpoint'] % seo_name)
    game_state = game_data_json['gameState']
    game_home_team = vars.params.get("home_team")
    game_visitor_team = vars.params.get("visitor_team")
    game_cameras = []
    if 'multiCameras' in game_data_json:
        game_cameras = game_data_json['multiCameras'].split(",")

    nba_config = Request.getJson(vars.config['config_endpoint'])
    nba_cameras = {}
    for camera in nba_config['content']['cameras']:
        nba_cameras[ camera['number'] ] = camera['name']

    if has_away_feed:
        # Create the "Home" and "Away" list items
        for ishomefeed in [True, False]:
            listitemname = "Full game, " + ("away feed" if not ishomefeed else "home feed")

            # Show actual team names instead of 'home feed' and 'away feed'
            if game_home_team and game_visitor_team:
                if ishomefeed:
                    listitemname += " (" + game_home_team + ")"
                else:
                    listitemname += " (" + game_visitor_team + ")"

            params = {
                'video_id': video_id,
                'video_type': video_type,
                'video_ishomefeed': 1 if ishomefeed else 0,
                'game_state': game_state,
                'start_time': start_time,
                'duration': duration,
            }
            common.addListItem(listitemname, url="", mode="playgame", iconimage="", customparams=params)
    else:
        #Add a "Home" list item
        params = {
            'video_id': video_id,
            'video_type': video_type,
            'game_state': game_state,
            'start_time': start_time,
            'duration': duration,
        }
        common.addListItem("Full game", url="", mode="playgame", iconimage="", customparams=params)

    if vars.show_cameras:
    
        #Add all the cameras available
        for camera_number in game_cameras:
            #Skip camera number 0 (broadcast?) - the full game links are the same
            camera_number = int(camera_number)
            if camera_number == 0:
                continue

            params = {
                'video_id': video_id,
                'video_type': video_type,
                'game_state': game_state,
                'camera_number': camera_number,
                'start_time': start_time,
                'duration': duration,
            }

            name = "Camera %d: %s" % (camera_number, nba_cameras[camera_number])
            common.addListItem(name
                , url="", mode="playgame", iconimage="", customparams=params)

    #Live games have no condensed or highlight link
    if video_type != "live":
        # Create the "Condensed" list item
        if has_condensed_game:
            params = {
                'video_id': video_id,
                'video_type': 'condensed',
                'game_state': game_state
            }
            common.addListItem("Condensed game", url="", mode="playgame", iconimage="", customparams=params)

        # Get the highlights video if available
        highlights_url = getHighlightGameUrl(video_id)
        if highlights_url:
            common.addVideoListItem("Highlights", highlights_url, iconimage="")

    xbmcplugin.endOfDirectory(handle = int(sys.argv[1]) )
开发者ID:maxgalbu,项目名称:xbmc.plugin.video.nba,代码行数:94,代码来源:games.py


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