-
Notifications
You must be signed in to change notification settings - Fork 19
Home
This library provides a pure python OEmbed consumer to get resources from OEmbed providers.
Based on reference from http://oembed.com/
oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.
OEmbed format authors:
- Cal Henderson (cal at iamcal.com)
- Mike Malone (mike at pownce.com)
- Leah Culver (leah at pownce.com)
- Richard Crowley (r at rcrowley.org)
Install the dependencies:
http://cheeseshop.python.org/pypi/simplejsonDownload the latest python-oembed library from:
git://github.com/abarmat/python-oembed.gitUntar the source distribution and run:
python setup.py build
python setup.py install
With setuptools installed:
$ python setup.py testWithout setuptools installed:
$ python oembed_test.pyTo create an instance of the oEmbed consumer:
import oembed
consumer = oembed.OEmbedConsumer()
To add a provider endpoint to this consumer:
- The first parameter is the URL of the endpoint published by the provider.
- The second parameter is the URL schema to use with this endpoint.
endpoint = oembed.OEmbedEndpoint('http://www.flickr.com/services/oembed', ['http://*.flickr.com/*'])
consumer.addEndpoint(endpoint)
To get the provider response for a URL:
response = consumer.embed('http://www.flickr.com/photos/wizardbt/2584979382/')
To print the response results (each field can be read as a python dict, None if empty):
print response['url']
import pprint
pprint.pprint(response.getData())
To read the full documentation:
$ pydoc oembed