def _build_provider_list():
    """
    Construct the provider registry, using the app settings.
    """
    registry = None
    if appsettings.FLUENT_OEMBED_SOURCE == 'basic':
        registry = bootstrap_basic()
    elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly':
        params = {}
        if appsettings.MICAWBER_EMBEDLY_KEY:
            params['key'] = appsettings.MICAWBER_EMBEDLY_KEY
        registry = bootstrap_embedly(**params)
    elif appsettings.FLUENT_OEMBED_SOURCE == 'noembed':
        registry = bootstrap_noembed(nowrap=1)
    elif appsettings.FLUENT_OEMBED_SOURCE == 'list':
        # Fill list manually in the settings, e.g. to have a fixed set of supported secure providers.
        registry = ProviderRegistry()
        for regex, provider in appsettings.FLUENT_OEMBED_PROVIDER_LIST:
            registry.register(regex, Provider(provider))
    else:
        raise ImproperlyConfigured("Invalid value of FLUENT_OEMBED_SOURCE, only 'basic', 'list', 'noembed' or 'embedly' is supported.")

    # Add any extra providers defined in the settings
    for regex, provider in appsettings.FLUENT_OEMBED_EXTRA_PROVIDERS:
        registry.register(regex, Provider(provider))

    return registry
Esempio n. 2
0
def _build_provider_list():
    """
    Construct the provider registry, using the app settings.
    """
    registry = None
    if appsettings.FLUENT_OEMBED_SOURCE == "basic":
        registry = bootstrap_basic()
    elif appsettings.FLUENT_OEMBED_SOURCE == "embedly":
        params = {}
        if appsettings.MICAWBER_EMBEDLY_KEY:
            params["key"] = appsettings.MICAWBER_EMBEDLY_KEY
        registry = bootstrap_embedly(**params)
    elif appsettings.FLUENT_OEMBED_SOURCE == "noembed":
        registry = bootstrap_noembed(nowrap=1)
    elif appsettings.FLUENT_OEMBED_SOURCE == "list":
        # Fill list manually in the settings, e.g. to have a fixed set of supported secure providers.
        registry = ProviderRegistry()
        for regex, provider in appsettings.FLUENT_OEMBED_PROVIDER_LIST:
            registry.register(regex, Provider(provider))
    else:
        raise ImproperlyConfigured(
            "Invalid value of FLUENT_OEMBED_SOURCE, only 'basic', 'list', 'noembed' or 'embedly' is supported."
        )

    # Add any extra providers defined in the settings
    for regex, provider in appsettings.FLUENT_OEMBED_EXTRA_PROVIDERS:
        registry.register(regex, Provider(provider))

    return registry
def _build_provider_list():
    """
    Construct the provider registry, using the app settings.
    """
    if appsettings.FLUENT_OEMBED_SOURCE == 'basic':
        registry = micawber.bootstrap_basic()
        # make sure http://youtu.be urls are also valid, see https://github.com/coleifer/micawber/pull/7
        registry.register('https?://(\S*.)?youtu(\.be/|be\.com/watch)\S*',
                          Provider('http://www.youtube.com/oembed'))
        return registry
    elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly':
        params = {}
        if appsettings.MICAWBER_EMBEDLY_KEY:
            params['key'] = appsettings.MICAWBER_EMBEDLY_KEY
        return micawber.bootstrap_embedly(**params)
    elif appsettings.FLUENT_OEMBED_SOURCE == 'list':
        # Fi
        registry = ProviderRegistry()
        for regex, provider in appsettings.FLUENT_OEMBED_PROVIDER_LIST:
            registry.register(regex, Provider(provider))
        return registry
    else:
        raise ImproperlyConfigured(
            "Invalid value of FLUENT_OEMBED_SOURCE, only 'basic', 'list' or 'embedly' is supported."
        )
Esempio n. 4
0
def main():
    print 'Please wait, loading providers from embed.ly'
    providers = bootstrap_embedly()

    while 1:
        url = raw_input('Enter a url (or q to quit): ')
        if url.lower().strip() == 'q':
            break

        try:
            result = providers.request(url)
        except ProviderException:
            print 'No provider found for that url :/'
        else:
            print 'Data for %s\n====================================================' % url
            pprint.pprint(result)
Esempio n. 5
0
def main():
    print('Please wait, loading providers from embed.ly')
    providers = bootstrap_embedly()

    while 1:
        url = read_input('Enter a url (or q to quit): ')
        if url.lower().strip() == 'q':
            break

        try:
            result = providers.request(url)
        except ProviderException:
            print('No provider found for that url :/')
        else:
            print('Data for %s\n====================================================' % url)
            pprint.pprint(result)
Esempio n. 6
0
def _build_provider_list():
    """
    Construct the provider registry, using the app settings.
    """
    if appsettings.FLUENT_OEMBED_SOURCE == 'basic':
        registry = micawber.bootstrap_basic()
        # make sure http://youtu.be urls are also valid, see https://github.com/coleifer/micawber/pull/7
        registry.register('https?://(\S*.)?youtu(\.be/|be\.com/watch)\S*', Provider('http://www.youtube.com/oembed'))
        return registry
    elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly':
        params = {}
        if appsettings.MICAWBER_EMBEDLY_KEY:
            params['key'] = appsettings.MICAWBER_EMBEDLY_KEY
        return micawber.bootstrap_embedly(**params)
    elif appsettings.FLUENT_OEMBED_SOURCE == 'list':
        # Fi
        registry = ProviderRegistry()
        for regex, provider in appsettings.FLUENT_OEMBED_PROVIDER_LIST:
            registry.register(regex, Provider(provider))
        return registry
    else:
        raise ImproperlyConfigured("Invalid value of FLUENT_OEMBED_SOURCE, only 'basic', 'list' or 'embedly' is supported.")