Esempio n. 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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
0
def roku_root_menu():
    # Roku config
    url = 'http://assets.espn.go.com/prod/assets/watchespn/roku/config.json'
    json_data = util.get_url_as_json_cache(get_url(url))
    for group in json_data['config']['featured']['groups']:
        if group['visibility'] == 'not authenticated':
            # This represents the duplicate Browse by Sport
            continue
        extra = ''
        if group['visibility'] == 'authenticated':
            if not adobe_activate_api.is_authenticated():
                extra = '*'
        if len(group['contents']) > 1:
            extra += group['name'] + ' - '
        for content in group['contents']:
            addDirectoryItem(
                plugin.handle,
                plugin.url_for(roku_url_mode, url=content['href']),
                ListItem(extra + content['name']), True)
    endOfDirectory(plugin.handle)
Esempio n. 7
0
def trending_mode():
    json_data = util.get_url_as_json_cache(get_url(WATCH_API_V1_TRENDING))
    for listing in json_data['listings']:
        index_listing(listing)
    for video in json_data['videos']:
        index_video(video)
Esempio n. 8
0
def roku_url_mode():
    url = arg_as_string('url')
    category_id = arg_as_string(ID)
    json_data = util.get_url_as_json_cache(get_url(url))
    if 'listings' in json_data:
        json_data['listings'].sort(key=functools.cmp_to_key(compare_roku))
        for listing in json_data['listings']:
            index_listing(listing)
        setContent(plugin.handle, 'episodes')
    if 'videos' in json_data:
        for video in json_data['videos']:
            index_video(video)
        setContent(plugin.handle, 'episodes')
    if 'categories' in json_data:
        for category in json_data['categories']:
            if category_id is None or category_id == '':
                if 'api' in category[
                        'links'] and 'subcategories' not in category:
                    addDirectoryItem(
                        plugin.handle,
                        plugin.url_for(
                            roku_url_mode,
                            url=category['links']['api']['video']['href']),
                        make_list_item(category['name'],
                                       get_thumbnail(category)), True)
                elif 'subcategories' in category:
                    # Collapse sub categories
                    for subcategory in category['subcategories']:
                        if 'api' in subcategory['links']:
                            addDirectoryItem(
                                plugin.handle,
                                plugin.url_for(roku_url_mode,
                                               url=subcategory['links']['api']
                                               ['video']['href']),
                                make_list_item(
                                    category['name'] +
                                    ' - ' + subcategory['name'],
                                    get_thumbnail(category)), True)
            elif category_id == str(category['id']):
                if 'api' in category['links']:
                    addDirectoryItem(
                        plugin.handle,
                        plugin.url_for(
                            roku_url_mode,
                            url=category['links']['api']['video']['href']),
                        make_list_item(category['name'] + ' - Clips',
                                       get_thumbnail(category)), True)
                if 'subcategories' in category:
                    for subcategory in category['subcategories']:
                        if 'api' in subcategory['links']:
                            addDirectoryItem(
                                plugin.handle,
                                plugin.url_for(roku_url_mode,
                                               url=subcategory['links']['api']
                                               ['video']['href']),
                                make_list_item(subcategory['name'],
                                               get_thumbnail(category)), True)
    if 'clients' in json_data:
        for client in json_data['clients']:
            for channel in client['channels']:
                addDirectoryItem(
                    plugin.handle,
                    plugin.url_for(
                        roku_url_mode,
                        url=channel['links']['api']['listings']['href']),
                    make_list_item(channel['name'], get_thumbnail(channel)),
                    True)
    endOfDirectory(plugin.handle)