Exemplo n.º 1
0
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]) )
Exemplo n.º 2
0
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 = utils.fetch_json(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 = utils.fetch_json(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:
        utils.log(nba_cameras, xbmc.LOGDEBUG)
        utils.log(game_cameras, xbmc.LOGDEBUG)

        # Add all the cameras available
        for camera_number in game_cameras:
            camera_number = int(camera_number)

            # Skip camera number 0 (broadcast?) - the full game links are the same
            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.get(camera_number, 'Unknown'))
            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]))
Exemplo n.º 3
0
def chooseGameVideoMenu(playlist=None, paramsX=None, in_a_hurry=False):
    if paramsX is None:
        paramsX = vars.params
    video_id = paramsX.get("video_id")
    video_type = paramsX.get("video_type")
    seo_name = paramsX.get("seo_name")
    has_away_feed = paramsX.get("has_away_feed", "0") == "1"
    has_condensed_game = paramsX.get("has_condensed_game", "0") == "1"
    start_time = paramsX.get("start_time")
    duration = paramsX.get("duration")
    game_data_json = json.loads(utils.fetch(vars.config['game_data_endpoint'] % seo_name))
    game_state = game_data_json['gameState']
    game_home_team = paramsX.get("home_team")
    game_visitor_team = paramsX.get("visitor_team")
    game_cameras = []
    foldername = paramsX.get("foldername")
    iconimage = paramsX.get('iconimage', "")
    if 'multiCameras' in game_data_json:
        game_cameras = game_data_json['multiCameras'].split(",")

    nba_config = json.loads(utils.fetch(vars.config['config_endpoint']))
    nba_cameras = {}
    for camera in nba_config['content']['cameras']:
        nba_cameras[camera['number']] = camera['name']

    streams = []

    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,
            }
            if playlist is None:
                common.addListItem(listitemname, url="", mode="playgame", iconimage=iconimage, customparams=params)
            else:
                streams.append([True, foldername + ' - ' + listitemname, get_link(url="", mode="playgame", 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,
        }
        if playlist is None:
            common.addListItem("Full game", url="", mode="playgame", iconimage=iconimage, customparams=params)
        else:
            streams.append([True, foldername + ' - Full game', get_link(url="", mode="playgame", customparams=params)])

    if vars.show_cameras:
        utils.log(nba_cameras, xbmc.LOGDEBUG)
        utils.log(game_cameras, xbmc.LOGDEBUG)

        # Add all the cameras available
        for camera_number in game_cameras:
            camera_number = int(camera_number)

            # Skip camera number 0 (broadcast?) - the full game links are the same
            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.get(camera_number, 'Unknown'))
            if playlist is None:
                common.addListItem(name, url="", mode="playgame", iconimage=iconimage, customparams=params)
            elif " ESPN" in name or " ABC" in name or " TNT" in name: #only interesting additional streams (also or "NBA TV" in name?), but not e.g. Spanish (ESPN)
                streams.append([True, foldername + ' - ' + name, get_link(url="", mode="playgame", customparams=params)])

    # Live games have no condensed or highlight link
    if video_type != "live":
        # Create the "Condensed" list item
        params = {
            'video_id': video_id,
            'video_type': 'condensed',
            'game_state': game_state,
        }
        if has_condensed_game:
            if playlist is None:
                common.addListItem("Condensed game", url="", mode="playgame", iconimage=iconimage, customparams=params)
        if playlist is not None: #manually add to playlist anyways, maybe will come online later...
            streams.append([False, foldername + ' - Condensed game', get_link(url="", mode="playgame", customparams=params)])

        # Get the highlights video if available
        highlights_url = getHighlightGameUrl(video_id)
        if highlights_url:
            if playlist is None:
                common.addVideoListItem("Highlights", highlights_url, iconimage=iconimage)
            else:
                streams.append([False, foldername + ' - Highlights', get_link(url=highlights_url)])

    if playlist is None:
        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
    else:
        #reorder playlist items before adding
        reorder_streams(streams, game_home_team, game_visitor_team, in_a_hurry)
        for s in streams:
            #trying to add thumbs to playlist item... (can't seem to get it as icon, but it is shown on the right and on the background. However, lost again when saving the playlist.)
            item = xbmcgui.ListItem(s[1], iconImage=iconimage, thumbnailImage=iconimage)
            try:
                art_keys = ['thumb', 'poster', 'banner', 'fanart', 'clearart', 'clearlogo', 'landscape', 'icon']
                art = dict(zip(art_keys, [iconimage for x in art_keys]))
                item.setArt(art)
                item.setInfo(type="video", infoLabels={"title": s[1]})
                item.setThumbnailImage(iconimage)
                item.setProperty('fanart_image', iconimage)
            except:
                pass
            playlist.add(s[2], item)