Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'))
from django.core.cache import cache
from micawber.providers import Provider, ProviderRegistry
oembed_providers = ProviderRegistry(cache)
oembed_providers.register(
r'http://\S*imgur\.com/\S+',
Provider('http://api.imgur.com/oembed')
),
oembed_providers.register(
r'https?://\S*?flickr.com/\S+',
Provider('https://www.flickr.com/services/oembed/')
)
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')
def bootstrap_noembed(cache=None, registry=None, **params):
endpoint = 'http://noembed.com/embed'
schema_url = 'http://noembed.com/providers'
pr = registry or ProviderRegistry(cache)
# fetch the schema
contents = fetch(schema_url)
json_data = json.loads(contents)
for provider_meta in json_data:
for regex in provider_meta['patterns']:
pr.register(regex, Provider(endpoint, **params))
return pr
def bootstrap_oembed(cache=None, registry=None, **params):
schema_url = 'https://oembed.com/providers.json'
pr = registry or ProviderRegistry(cache)
# Fetch schema.
contents = fetch(schema_url)
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:
def bootstrap_embedly(cache=None, registry=None, **params):
endpoint = 'http://api.embed.ly/1/oembed'
schema_url = 'http://api.embed.ly/1/services/python'
pr = registry or ProviderRegistry(cache)
# fetch the schema
contents = fetch(schema_url)
json_data = json.loads(contents)
for provider_meta in json_data:
for regex in provider_meta['regex']:
pr.register(regex, Provider(endpoint, **params))
return pr