コード例 #1
0
def resolve(video_id):
    provider = Provider()
    context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)
    streams = client.get_video_streams(context=context, video_id=video_id)
    sorted_streams = sorted(streams, key=lambda x: x.get('sort', 0), reverse=True)
    return sorted_streams
def _get_core_components(addon_id=None):
    provider = Provider()
    if addon_id is not None:
        context = Context(params={'addon_id': addon_id}, plugin_id='plugin.video.youtube')
    else:
        context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)

    return provider, context, client
コード例 #3
0
def _get_core_components(addon_id=None):
    provider = Provider()
    if addon_id is not None:
        context = Context(params={'addon_id': addon_id}, plugin_id='plugin.video.youtube')
    else:
        context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)

    return provider, context, client
コード例 #4
0
 def get_media_url(self, host, media_id):
     if Provider is None or Context is None:
         return 'plugin://plugin.video.youtube/play/?video_id=' + media_id
     else:
         provider = Provider()
         context = Context(plugin_id='plugin.video.youtube')
         client = provider.get_client(context=context)
         streams = client.get_video_streams(context=context, video_id=media_id)
         streams_no_dash = [item for item in streams if item['container'] != 'mpd']
         sorted_streams = sorted(streams_no_dash, key=lambda x: x.get('sort', 0), reverse=True)
         sorted_streams = [(item['title'], item['url']) for item in sorted_streams]
         return helpers.pick_source(sorted_streams)
コード例 #5
0
def __get_core_components(addon_id=None):
    """
    :param addon_id: addon id associated with developer keys to use for requests
    :return: addon provider, context and client 
    """
    provider = Provider()
    if addon_id is not None:
        context = Context(params={'addon_id': addon_id}, plugin_id='plugin.video.youtube')
    else:
        context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)

    return provider, context, client
コード例 #6
0
def __get_core_components(addon_id=None):
    """
    :param addon_id: addon id associated with developer keys to use for requests
    :return: addon provider, context and client 
    """
    provider = Provider()
    if addon_id is not None:
        context = Context(params={'addon_id': addon_id}, plugin_id='plugin.video.youtube')
    else:
        context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)

    return provider, context, client
コード例 #7
0
def __auth(addon_id, mode=SIGN_IN):
    """

    :param addon_id: id of the add-on being signed in
    :param mode: SIGN_IN or SIGN_OUT
    :return: addon provider, context and client
    """
    if not addon_id or addon_id == 'plugin.video.youtube':
        context = Context(plugin_id='plugin.video.youtube')
        context.log_error('Developer authentication: |%s| Invalid addon_id' % addon_id)
        return
    __add_new_developer(addon_id)
    params = {'addon_id': addon_id}
    provider = Provider()
    context = Context(params=params, plugin_id='plugin.video.youtube')

    _ = provider.get_client(context=context)  # NOQA
    logged_in = provider.is_logged_in()
    if mode == SIGN_IN:
        if logged_in:
            return True
        else:
            provider.reset_client()
            yt_login.process(mode, provider, context, sign_out_refresh=False)
    elif mode == SIGN_OUT:
        if not logged_in:
            return True
        else:
            provider.reset_client()
            try:
                yt_login.process(mode, provider, context, sign_out_refresh=False)
            except:
                reset_access_tokens(addon_id)
    else:
        raise Exception('Unknown mode: |%s|' % mode)

    _ = provider.get_client(context=context)  # NOQA
    if mode == SIGN_IN:
        return provider.is_logged_in()
    else:
        return not provider.is_logged_in()
コード例 #8
0
def _get_core_components():
    provider = Provider()
    context = Context(plugin_id='plugin.video.youtube')
    client = provider.get_client(context=context)

    return provider, context, client
コード例 #9
0
def __auth(addon_id, mode=SIGN_IN):
    """

    :param addon_id: id of the add-on being signed in
    :param mode: SIGN_IN or SIGN_OUT
    :return: addon provider, context and client
    """
    if not addon_id or addon_id == 'plugin.video.youtube':
        context = Context(plugin_id='plugin.video.youtube')
        context.log_error('Developer authentication: |%s| Invalid addon_id' %
                          addon_id)
        return
    __add_new_developer(addon_id)
    params = {'addon_id': addon_id}
    provider = Provider()
    context = Context(params=params, plugin_id='plugin.video.youtube')

    _ = provider.get_client(context=context)  # NOQA
    logged_in = provider.is_logged_in()
    if mode == SIGN_IN:
        if logged_in:
            return True
        else:
            provider.reset_client()
            yt_login.process(mode, provider, context, sign_out_refresh=False)
    elif mode == SIGN_OUT:
        if not logged_in:
            return True
        else:
            provider.reset_client()
            try:
                yt_login.process(mode,
                                 provider,
                                 context,
                                 sign_out_refresh=False)
            except:
                reset_access_tokens(addon_id)
    else:
        raise Exception('Unknown mode: |%s|' % mode)

    _ = provider.get_client(context=context)  # NOQA
    if mode == SIGN_IN:
        return provider.is_logged_in()
    else:
        return not provider.is_logged_in()