def play_tv(event_id):
    resource = arg_as_string('resource')
    network_name = arg_as_string('network_name')

    auth_types = get_auth_types_from_network(network_name)
    media_token = check_auth_status(auth_types, [], resource, network_name)
    if media_token is None:
        return
    token_type = get_token_type(auth_types)

    # see aHR0cDovL2FwaS1hcHAuZXNwbi5jb20vdjEvd2F0Y2gvY2xpZW50cy93YXRjaGVzcG4tdHZvcw== for details
    # see aHR0cDovL2VzcG4uZ28uY29tL3dhdGNoZXNwbi9hcHBsZXR2L2ZlYXR1cmVk for details
    start_session_url = arg_as_string('session_url')

    start_session(media_token, token_type, resource, start_session_url)
Example #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)
def upcoming_event(event_id):
    starttime = arg_as_string('starttime')
    event_name = unquote_plus(arg_as_string('event_name'))
    packages = arg_as_list('packages')
    entitlements = espnplus.get_entitlements()
    logging.debug('Upcoming event chosen for %s, %s, %s' %
                  (starttime, packages, entitlements))
    has_entitlement = is_entitled(packages, entitlements)
    logging.debug('Entitled for content? %s' % has_entitlement)
    extra = ''
    if not has_entitlement:
        extra = get_string(40270) % (', '.join(packages))
    dialog = xbmcgui.Dialog()
    dialog.ok(get_string(30035),
              get_string(30036) % (event_name, starttime, extra))
    endOfDirectory(plugin.handle, succeeded=False, updateListing=True)
def play_event(event_id):
    event_url = arg_as_string('event_url')
    auth_types = arg_as_list('auth_types')
    packages = arg_as_list('packages')

    session_json = util.get_url_as_json(event_url)
    resource = session_json['adobeRSS']
    network_name = session_json['tracking']['network']

    logging.debug('Checking current auth of %s %s %s' %
                  (auth_types, packages, network_name))
    media_token = check_auth_status(auth_types, packages, resource,
                                    network_name)
    token_type = get_token_type(auth_types)

    if token_type is None or media_token is None:
        endOfDirectory(plugin.handle, succeeded=False, updateListing=True)
    else:
        start_session_url = session_json['playbackState']['videoHref']
        start_session(media_token, token_type, resource, start_session_url)
Example #5
0
def search_results():
    search_query = arg_as_string('q')
    handle_search(search_query)
Example #6
0
def live_sport_events_mode(sport):
    espn_url = arg_as_string('espn_url')
    index_legacy_live_events(espn_url, sport=sport)
    xbmcplugin.setContent(plugin.handle, 'episodes')
    xbmcplugin.endOfDirectory(plugin.handle)
Example #7
0
def live_network_events_mode(network_id):
    espn_url = arg_as_string('espn_url')
    index_legacy_live_events(espn_url, network_id=network_id)
    xbmcplugin.setContent(plugin.handle, 'episodes')
    xbmcplugin.endOfDirectory(plugin.handle)
Example #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)
Example #9
0
def page_api_buckets(bucket_path):
    bucket_url = arg_as_string('bucket_url')
    parse_json(bucket_url, bucket_path)
    endOfDirectory(plugin.handle)
Example #10
0
def page_api_channel():
    url = arg_as_string('url')
    channel_id = arg_as_string('channel_id')
    parse_json(url, channel_id=channel_id)
    endOfDirectory(plugin.handle)
Example #11
0
def page_api_url_bucket(bucket_id):
    url = arg_as_string('url')
    parse_json(url)
    endOfDirectory(plugin.handle)
def play_vod(event_id):
    url = arg_as_string('url')
    session_json = util.get_url_as_json(url)
    playback_url = session_json['playbackState']['videoHref']

    process_playback_url(playback_url, '')
def play_item(event_id):
    url = arg_as_string('url')
    item = xbmcgui.ListItem(path=url)
    return setResolvedUrl(plugin.handle, True, item)