How to use the micawber.providers.Provider function in micawber

To help you get started, we’ve selected a few micawber examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coleifer / micawber / micawber / providers.py View on Github external
pattern = scheme.replace('*', r'[^\/\s\?&]+?')
                try:
                    re.compile(pattern)
                except re.error:
                    logger.exception('oembed.com provider %s regex could not '
                                     'be compiled: %s', url, pattern)
                    continue

                pr.register(pattern, provider)

    # Currently oembed.com does not provide patterns for YouTube, so we'll add
    # these ourselves.
    pr.register(r'http://(\S*\.)?youtu(\.be/|be\.com/watch)\S+',
                Provider('http://www.youtube.com/oembed'))
    pr.register(r'https://(\S*\.)?youtu(\.be/|be\.com/watch)\S+',
                Provider('http://www.youtube.com/oembed?scheme=https&'))

    return pr
github coleifer / micawber / micawber / providers.py View on Github external
def bootstrap_basic(cache=None, registry=None):
    # complements of oembed.com#section7
    pr = registry or ProviderRegistry(cache)

    # c
    pr.register(r'http://chirb\.it/\S+', Provider('http://chirb.it/oembed.json'))
    pr.register(r'https?://www\.circuitlab\.com/circuit/\S+', Provider('https://www.circuitlab.com/circuit/oembed'))

    # d
    pr.register(r'https?://(?:www\.)?dailymotion\.com/\S+', Provider('http://www.dailymotion.com/services/oembed'))

    # f
    pr.register(r'https?://\S*?flickr\.com/\S+', Provider('https://www.flickr.com/services/oembed/'))
    pr.register(r'https?://flic\.kr/\S*', Provider('https://www.flickr.com/services/oembed/'))
    pr.register(r'https?://(?:www\.)?funnyordie\.com/videos/\S+', Provider('http://www.funnyordie.com/oembed'))

    # g
    pr.register(r'https?://gist\.github\.com/\S*', Provider('https://github.com/api/oembed'))

    # h
    pr.register(r'http://(?:www\.)hulu\.com/watch/\S+', Provider('http://www.hulu.com/api/oembed.json'))

    # i
    pr.register(r'https?://\S*imgur\.com/\S+', Provider('https://api.imgur.com/oembed')),
    pr.register(r'https?://(www\.)?instagr(\.am|am\.com)/p/\S+', Provider('http://api.instagram.com/oembed'))
github liqd / a4-opin / euth / contrib / oembed.py View on Github external
)
oembed_providers.register(
    r'https://\S*?soundcloud.com/\S+',
    Provider('http://soundcloud.com/oembed')
)
oembed_providers.register(
    r'http://vimeo.com/\S+',
    Provider('http://vimeo.com/api/oembed.json')
)
oembed_providers.register(
    r'https://vimeo.com/\S+',
    Provider('https://vimeo.com/api/oembed.json')
)
oembed_providers.register(
    r'http://(\S*.)?youtu(\.be/|be\.com/watch)\S+',
    Provider('http://www.youtube.com/oembed')
)
oembed_providers.register(
    r'https://(\S*.)?youtu(\.be/|be\.com/watch)\S+',
    Provider('http://www.youtube.com/oembed?scheme=https&')
)
oembed_providers.register(
    r'https?://www.instagr(\.am|am\.com)/p/\S+',
    Provider('http://api.instagram.com/oembed')
)
oembed_providers.register(
    r'https?://www.facebook.com/\S+/videos/\S+',
    Provider('https://www.facebook.com/plugins/video/oembed.json')
)
oembed_providers.register(
    r'https?://www.facebook.com/video.php\?(id|v)=\S+',
    Provider('https://www.facebook.com/plugins/video/oembed.json')
github liqd / a4-opin / euth / contrib / oembed.py View on Github external
)
oembed_providers.register(
    r'https?://flic\.kr/\S*',
    Provider('https://www.flickr.com/services/oembed/')
)
oembed_providers.register(
    r'http://i\S*.photobucket.com/albums/\S+',
    Provider('http://photobucket.com/oembed')
)
oembed_providers.register(
    r'http://gi\S*.photobucket.com/groups/\S+',
    Provider('http://photobucket.com/oembed')
)
oembed_providers.register(
    r'https://\S*?soundcloud.com/\S+',
    Provider('http://soundcloud.com/oembed')
)
oembed_providers.register(
    r'http://vimeo.com/\S+',
    Provider('http://vimeo.com/api/oembed.json')
)
oembed_providers.register(
    r'https://vimeo.com/\S+',
    Provider('https://vimeo.com/api/oembed.json')
)
oembed_providers.register(
    r'http://(\S*.)?youtu(\.be/|be\.com/watch)\S+',
    Provider('http://www.youtube.com/oembed')
)
oembed_providers.register(
    r'https://(\S*.)?youtu(\.be/|be\.com/watch)\S+',
    Provider('http://www.youtube.com/oembed?scheme=https&')
github coleifer / micawber / micawber / providers.py View on Github external
# or more of any character that is not a slash, whitespace, or
                # a parameter used for separating querystring/url params.
                pattern = scheme.replace('*', r'[^\/\s\?&]+?')
                try:
                    re.compile(pattern)
                except re.error:
                    logger.exception('oembed.com provider %s regex could not '
                                     'be compiled: %s', url, pattern)
                    continue

                pr.register(pattern, provider)

    # Currently oembed.com does not provide patterns for YouTube, so we'll add
    # these ourselves.
    pr.register(r'http://(\S*\.)?youtu(\.be/|be\.com/watch)\S+',
                Provider('http://www.youtube.com/oembed'))
    pr.register(r'https://(\S*\.)?youtu(\.be/|be\.com/watch)\S+',
                Provider('http://www.youtube.com/oembed?scheme=https&'))

    return pr
github coleifer / micawber / micawber / providers.py View on Github external
pr.register(r'http://chirb\.it/\S+', Provider('http://chirb.it/oembed.json'))
    pr.register(r'https?://www\.circuitlab\.com/circuit/\S+', Provider('https://www.circuitlab.com/circuit/oembed'))

    # d
    pr.register(r'https?://(?:www\.)?dailymotion\.com/\S+', Provider('http://www.dailymotion.com/services/oembed'))

    # f
    pr.register(r'https?://\S*?flickr\.com/\S+', Provider('https://www.flickr.com/services/oembed/'))
    pr.register(r'https?://flic\.kr/\S*', Provider('https://www.flickr.com/services/oembed/'))
    pr.register(r'https?://(?:www\.)?funnyordie\.com/videos/\S+', Provider('http://www.funnyordie.com/oembed'))

    # g
    pr.register(r'https?://gist\.github\.com/\S*', Provider('https://github.com/api/oembed'))

    # h
    pr.register(r'http://(?:www\.)hulu\.com/watch/\S+', Provider('http://www.hulu.com/api/oembed.json'))

    # i
    pr.register(r'https?://\S*imgur\.com/\S+', Provider('https://api.imgur.com/oembed')),
    pr.register(r'https?://(www\.)?instagr(\.am|am\.com)/p/\S+', Provider('http://api.instagram.com/oembed'))

    # m
    pr.register(r'http://www\.mobypicture\.com/user/\S*?/view/\S*', Provider('http://api.mobypicture.com/oEmbed'))
    pr.register(r'http://moby\.to/\S*', Provider('http://api.mobypicture.com/oEmbed'))

    # p
    pr.register(r'http://i\S*\.photobucket\.com/albums/\S+', Provider('http://photobucket.com/oembed'))
    pr.register(r'http://gi\S*\.photobucket\.com/groups/\S+', Provider('http://photobucket.com/oembed'))
    pr.register(r'http://www\.polleverywhere\.com/(polls|multiple_choice_polls|free_text_polls)/\S+', Provider('http://www.polleverywhere.com/services/oembed/'))
    pr.register(r'https?://(.+\.)?polldaddy\.com/\S*', Provider('http://polldaddy.com/oembed/'))

    # s
github coleifer / micawber / micawber / providers.py View on Github external
json_data = json.loads(contents)

    for item in json_data:
        for endpoint in item['endpoints']:
            # Possibly this provider only supports discovery via  tags,
            # which is not supported by micawber.
            if 'schemes' not in endpoint:
                continue

            # Consists of one or more schemes, a destination URL and optionally
            # a format, e.g. "json".
            url = endpoint['url']
            if '{format}' in url:
                url = url.replace('{format}', 'json')

            provider = Provider(url, **params)
            for scheme in endpoint['schemes']:
                # If a question-mark is being used, it is for the query-string
                # and should be treated as a literal.
                scheme = scheme.replace('?', '\?')

                # Transform the raw pattern into a reasonable regex. Match one
                # or more of any character that is not a slash, whitespace, or
                # a parameter used for separating querystring/url params.
                pattern = scheme.replace('*', r'[^\/\s\?&]+?')
                try:
                    re.compile(pattern)
                except re.error:
                    logger.exception('oembed.com provider %s regex could not '
                                     'be compiled: %s', url, pattern)
                    continue
github coleifer / micawber / micawber / providers.py View on Github external
# m
    pr.register(r'http://www\.mobypicture\.com/user/\S*?/view/\S*', Provider('http://api.mobypicture.com/oEmbed'))
    pr.register(r'http://moby\.to/\S*', Provider('http://api.mobypicture.com/oEmbed'))

    # p
    pr.register(r'http://i\S*\.photobucket\.com/albums/\S+', Provider('http://photobucket.com/oembed'))
    pr.register(r'http://gi\S*\.photobucket\.com/groups/\S+', Provider('http://photobucket.com/oembed'))
    pr.register(r'http://www\.polleverywhere\.com/(polls|multiple_choice_polls|free_text_polls)/\S+', Provider('http://www.polleverywhere.com/services/oembed/'))
    pr.register(r'https?://(.+\.)?polldaddy\.com/\S*', Provider('http://polldaddy.com/oembed/'))

    # s
    pr.register(r'https?://(?:www\.)?slideshare\.net/[^\/]+/\S+', Provider('http://www.slideshare.net/api/oembed/2'))
    pr.register(r'https?://slidesha\.re/\S*', Provider('http://www.slideshare.net/api/oembed/2'))
    pr.register(r'http://\S*\.smugmug\.com/\S*', Provider('http://api.smugmug.com/services/oembed/'))
    pr.register(r'https://\S*?soundcloud\.com/\S+', Provider('http://soundcloud.com/oembed'))
    pr.register(r'https?://speakerdeck\.com/\S*', Provider('https://speakerdeck.com/oembed.json')),
    pr.register(r'https?://(?:www\.)?scribd\.com/\S*', Provider('http://www.scribd.com/services/oembed'))

    # t
    pr.register(r'https?://(www\.)?twitter\.com/\S+/status(es)?/\S+', Provider('https://publish.twitter.com/oembed'))

    # v
    pr.register(r'http://vimeo\.com/\S+', Provider('http://vimeo.com/api/oembed.json'))
    pr.register(r'https://vimeo\.com/\S+', Provider('https://vimeo.com/api/oembed.json'))

    # w
    pr.register(r'http://\S+\.wordpress\.com/\S+', Provider('http://public-api.wordpress.com/oembed/'))
    pr.register(r'https?://wordpress\.tv/\S+', Provider('http://wordpress.tv/oembed/'))

    # y
    pr.register(r'http://(\S*\.)?youtu(\.be/|be\.com/watch)\S+', Provider('http://www.youtube.com/oembed'))
    pr.register(r'https://(\S*\.)?youtu(\.be/|be\.com/watch)\S+', Provider('http://www.youtube.com/oembed?scheme=https&'))
github coleifer / micawber / micawber / providers.py View on Github external
pr.register(r'https?://(.+\.)?polldaddy\.com/\S*', Provider('http://polldaddy.com/oembed/'))

    # s
    pr.register(r'https?://(?:www\.)?slideshare\.net/[^\/]+/\S+', Provider('http://www.slideshare.net/api/oembed/2'))
    pr.register(r'https?://slidesha\.re/\S*', Provider('http://www.slideshare.net/api/oembed/2'))
    pr.register(r'http://\S*\.smugmug\.com/\S*', Provider('http://api.smugmug.com/services/oembed/'))
    pr.register(r'https://\S*?soundcloud\.com/\S+', Provider('http://soundcloud.com/oembed'))
    pr.register(r'https?://speakerdeck\.com/\S*', Provider('https://speakerdeck.com/oembed.json')),
    pr.register(r'https?://(?:www\.)?scribd\.com/\S*', Provider('http://www.scribd.com/services/oembed'))

    # t
    pr.register(r'https?://(www\.)?twitter\.com/\S+/status(es)?/\S+', Provider('https://publish.twitter.com/oembed'))

    # v
    pr.register(r'http://vimeo\.com/\S+', Provider('http://vimeo.com/api/oembed.json'))
    pr.register(r'https://vimeo\.com/\S+', Provider('https://vimeo.com/api/oembed.json'))

    # w
    pr.register(r'http://\S+\.wordpress\.com/\S+', Provider('http://public-api.wordpress.com/oembed/'))
    pr.register(r'https?://wordpress\.tv/\S+', Provider('http://wordpress.tv/oembed/'))

    # y
    pr.register(r'http://(\S*\.)?youtu(\.be/|be\.com/watch)\S+', Provider('http://www.youtube.com/oembed'))
    pr.register(r'https://(\S*\.)?youtu(\.be/|be\.com/watch)\S+', Provider('http://www.youtube.com/oembed?scheme=https&'))

    return pr
github armadillica / dillo / dillo / __init__.py View on Github external
def __init__(self):
        self._log = logging.getLogger('%s.DilloExtension' % __name__)

        self.oembed_registry = bootstrap_basic()
        self.oembed_registry.register(
            'https?://sketchfab.com/models/*',
            Provider('https://sketchfab.com/oembed'))
        self.oembed_registry.register(
            'https?://p3d.in/*',
            Provider('https://p3d.in/oembed'))
        self.oembed_registry.register(
            'https?://instagram.com/p/*',
            Provider('http://api.instagram.com/oembed'))
        self.has_context_processor = True