示例#1
0
def appletv_showcase():
    url = arg_as_string('url')
    selected_nav_id = arg_as_string('nav_id')
    et = util.get_url_as_xml_cache(get_url(url))
    navigation_items = et.findall('.//navigation/navigationItem')
    logging.debug('Found %s items' % len(navigation_items))
    if selected_nav_id == '' and len(navigation_items) > 0:
        for navigation_item in navigation_items:
            name = navigation_item.find('./title').text
            nav_id = navigation_item.get('id')
            menu_item = navigation_item.find('.//twoLineMenuItem')
            if menu_item is None:
                menu_item = navigation_item.find('.//twoLineEnhancedMenuItem')
            if menu_item is not None and not menu_item.get('id') == 'no-event':
                addDirectoryItem(
                    plugin.handle,
                    plugin.url_for(appletv_showcase, url=url, nav_id=nav_id),
                    make_list_item(name), True)
    elif len(navigation_items) > 0:
        for navigation_item in navigation_items:
            if str(navigation_item.get('id')) == selected_nav_id:
                logging.debug('Found nav item %s' % selected_nav_id)
                process_item_list(
                    navigation_item.findall('.//twoLineMenuItem'))
                process_item_list(
                    navigation_item.findall('.//twoLineEnhancedMenuItem'))
                setContent(plugin.handle, 'episodes')
    else:  # If there are no navigation items then just dump all of the menu entries
        logging.debug('Dumping all menu items')
        process_item_list(et.findall('.//twoLineMenuItem'))
        process_item_list(et.findall('.//twoLineEnhancedMenuItem'))
        setContent(plugin.handle, 'episodes')
    endOfDirectory(plugin.handle)
示例#2
0
def list_sports():
    espn_url = arg_as_string('espn_url')
    if 'action=replay' in espn_url:
        image = defaultreplay
    elif 'action=upcoming' in espn_url:
        image = defaultupcoming
    else:
        image = None
    addDirectoryItem(plugin.handle,
                     plugin.url_for(live_events_mode, espn_url=espn_url),
                     make_list_item(get_string(30034), icon=image), True)
    sports = []
    sport_elements = util.get_url_as_xml_cache(espn_url).findall(
        './/sportDisplayValue')
    for sport in sport_elements:
        sport = sport.text.encode('utf-8')
        if sport not in sports:
            sports.append(sport)
    for sport in sports:
        addDirectoryItem(
            plugin.handle,
            plugin.url_for(live_sport_events_mode,
                           sport=sport,
                           espn_url=espn_url), make_list_item(sport,
                                                              icon=image),
            True)

    xbmcplugin.addSortMethod(plugin.handle,
                             xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE)
    xbmcplugin.endOfDirectory(plugin.handle)
示例#3
0
def appletv_shelf(shelf_id):
    et = util.get_url_as_xml_cache(get_url(APPLE_TV_FEATURED))
    for shelf in et.findall('.//shelf'):
        name = shelf.get('id')
        if name == shelf_id:
            process_item_list(shelf.findall('.//sixteenByNinePoster'))
    setContent(plugin.handle, 'episodes')
    endOfDirectory(plugin.handle)
示例#4
0
def appletv_channels():
    et = util.get_url_as_xml_cache(get_url(APPLE_TV_CHANNELS))
    for channel in et.findall('.//oneLineMenuItem'):
        name = channel.get('accessibilityLabel')
        image = channel.find('.//image').text
        url = util.parse_url_from_method(channel.get('onSelect'))
        addDirectoryItem(plugin.handle,
                         plugin.url_for(appletv_showcase, url=url),
                         make_list_item(name, image), True)
    setContent(plugin.handle, 'episodes')
    endOfDirectory(plugin.handle, updateListing=False)
示例#5
0
def appletv_sports():
    et = util.get_url_as_xml_cache(get_url(APPLE_TV_SPORTS))
    images = et.findall('.//image')
    sports = et.findall('.//oneLineMenuItem')
    for i in range(0, min(len(images), len(sports))):
        sport = sports[i]
        image = images[i]
        name = sport.get('accessibilityLabel')
        image = image.text
        url = util.parse_url_from_method(sport.get('onSelect'))
        addDirectoryItem(plugin.handle,
                         plugin.url_for(appletv_showcase, url=url),
                         make_list_item(name, image), True)
    endOfDirectory(plugin.handle, updateListing=False)
示例#6
0
def appletv_featured():
    et = util.get_url_as_xml_cache(get_url(APPLE_TV_FEATURED))
    for showcase in et.findall('.//showcase/items/showcasePoster'):
        name = showcase.get('accessibilityLabel')
        image = showcase.find('./image').get('src')
        url = util.parse_url_from_method(showcase.get('onPlay'))
        addDirectoryItem(plugin.handle,
                         plugin.url_for(appletv_showcase, url=url),
                         make_list_item(name, image), True)
    collections = et.findall('.//collectionDivider')
    shelfs = et.findall('.//shelf')
    for i in range(0, len(collections)):
        collection_divider = collections[i]
        shelf = shelfs[i]
        title = collection_divider.find('title').text
        name = shelf.get('id')
        addDirectoryItem(plugin.handle,
                         plugin.url_for(appletv_shelf, shelf_id=name),
                         make_list_item(title), True)
    endOfDirectory(plugin.handle)
示例#7
0
def index_legacy_live_events(espn_url, sport=None, network_id=None):
    chosen_sport = sport
    chosen_network = network_id
    live = 'action=live' in espn_url
    upcoming = 'action=upcoming' in espn_url
    replay = 'action=replay' in espn_url
    if live:
        data = events.get_events(espn_url)
    else:
        data = util.get_url_as_xml_cache(
            espn_url, encoding='ISO-8859-1').findall(".//event")
    num_espn3 = 0
    num_secplus = 0
    num_accextra = 0
    num_events = 0
    for event in data:
        sport = event.find('sportDisplayValue').text.encode('utf-8')
        if chosen_sport != sport and chosen_sport is not None:
            continue
        networkid = event.find('networkId').text
        if chosen_network != networkid and chosen_network is not None:
            continue
        if networkid == ESPN3_ID and chosen_network is None and live:
            num_espn3 += 1
        elif networkid == SECPLUS_ID and chosen_network is None and live:
            num_secplus += 1
        elif networkid == ACC_EXTRA_ID and chosen_network is None and live:
            num_accextra += 1
        else:
            num_events += 1
            _index_event(event, live, upcoming, replay, chosen_sport)
    # Don't show ESPN3 folder if there are no premium events
    if num_events == 0:
        for event in data:
            sport = event.find('sportDisplayValue').text.encode('utf-8')
            if chosen_sport != sport and chosen_sport is not None:
                continue
            _index_event(event, live, upcoming, replay, chosen_sport)
    # Dir for ESPN3/SECPlus/ACC Extra
    elif chosen_network is None:
        if num_espn3 > 0 and get_setting_as_bool('ShowEspn3'):
            translation_number = 30191 if num_espn3 == 1 else 30190
            name = (get_string(translation_number) % num_espn3)
            addDirectoryItem(
                plugin.handle,
                plugin.url_for(live_network_events_mode,
                               espn_url=espn_url,
                               network_id=ESPN3_ID), make_list_item(name),
                True)
        if num_secplus > 0 and get_setting_as_bool('ShowSecPlus'):
            translation_number = 30201 if num_secplus == 1 else 30200
            name = (get_string(translation_number) % num_secplus)
            addDirectoryItem(
                plugin.handle,
                plugin.url_for(live_network_events_mode,
                               espn_url=espn_url,
                               network_id=SECPLUS_ID), make_list_item(name),
                True)
        if num_accextra > 0 and get_setting_as_bool('ShowAccExtra'):
            translation_number = 30203 if num_accextra == 1 else 30202
            name = (get_string(translation_number) % num_accextra)
            addDirectoryItem(
                plugin.handle,
                plugin.url_for(live_network_events_mode,
                               espn_url=espn_url,
                               network_id=ACC_EXTRA_ID), make_list_item(name),
                True)
示例#8
0
def get_config():
    return util.get_url_as_xml_cache(PLAYER_CONFIG_URL, PLAYER_CONFIG_FILE,
                                     TIME_DIFFERENCE)
示例#9
0
def get_events(url):
    et = util.get_url_as_xml_cache(url, encoding='ISO-8859-1')
    return et.findall('.//event')
示例#10
0
def get_live_events(network_names=None):
    if network_names is None:
        network_names = []
    et = util.get_url_as_xml_cache(player_config.get_live_event_url(),
                                   encoding='ISO-8859-1')
    return et.findall('.//event')