Created
March 18, 2010 07:51
-
-
Save embedly/336134 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an implementation using python-oembed with api.embed.ly | |
# python-oembed http://code.google.com/p/python-oembed/ | |
import oembed | |
# Embed.ly Multi Provider API Endpoint | |
OEMBED_ENDPOINT = 'http://api.embed.ly/oembed/api/v1' | |
# URL Schemes Supported --- complete list maintained | |
# http://api.embed.ly/static/data/embedly_regex.json | |
URL_SCHEMES = ( | |
'http://www.5min.com/Video/*', | |
'http://*.viddler.com/explore/*/videos/*', | |
'http://qik.(ly|com)/video/*', | |
'http://qik.(ly|com)/*', | |
'http://www.hulu.com/watch/*', | |
'http://*.revision3.com/*', | |
'http://*nfb.ca/film/*', | |
'http://*.dailymotion.com/video/*', | |
'http://blip.tv/file/*', | |
'http://*.scribd.com/doc/*', | |
'http://*.movieclips.com/watch/*', | |
'http://screenr.com/.+', | |
'http://twitpic.com/*', | |
'http://*.youtube.com/watch*', | |
'http://yfrog.*/*', | |
'http://*amazon.*/gp/product/*', | |
'http://*amazon.*/*/dp/*', | |
'http://*flickr.com/*', | |
'http://www.vimeo.com/groups/*/videos/*', | |
'http://www.vimeo.com/*', | |
'http://tweetphoto.com/*', | |
'http://www.collegehumor.com/video:*', | |
'http://www.funnyordie.com/videos/*', | |
'http://video.google.com/videoplay?*', | |
'http://www.break.com/*/*', | |
'http://www.slideshare.net/*/*', | |
'http://www.ustream.tv/recorded/*', | |
'http://www.ustream.tv/channel/*', | |
'http://www.twitvid.com/*', | |
'http://www.justin.tv/clip/*', | |
'http://www.justin.tv/*', | |
'http://vids.myspace.com/index.cfm\?fuseaction=vids.individual&videoid*', | |
'http://www.metacafe.com/watch/*', | |
'http://*crackle.com/c/*', | |
'http://www.veoh.com/*/watch/*', | |
'http://www.fancast.com/(tv|movies)/*/videos', | |
'http://*imgur.com/*', | |
'http://*.posterous.com/*', | |
) | |
def get_oembed(url, format='json', maxwidth=None, maxheight=None): | |
# create consumer and API endpoint | |
consumer = oembed.OEmbedConsumer() | |
endpoint = oembed.OEmbedEndpoint(OEMBED_ENDPOINT, URL_SCHEMES) | |
consumer.addEndpoint(endpoint) | |
# gather maxwidth or maxheight options for embed sizing | |
options = [] | |
if maxwidth is not None: | |
opt['maxwidth'] = maxwidth | |
if maxheight is not None: | |
opt['maxheight'] = maxheight | |
response = consumer.embed(url, format, **options) | |
return response.getData() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment