Skip to main content

pyoembed

https://ci.rgm.io/buildStatus/icon?job=pyoembed

A Python library for oEmbed that supports auto-discovered and manually included providers.

Installation

$ pip install pyoembed

Usage

The library provides a function that should be called to automatically embed the url content, and it is called oEmbed:

from pyoembed import oEmbed, PyOembedException

try:
    # maxwidth and maxheight are optional.
    data = oEmbed('http://www.youtube.com/watch?v=_PEdPBEpQfY',
                  maxwidth=640, maxheight=480)
except PyOembedException, e:
    print 'An error was ocurred: %s' % e

# data is a dict with keys that will depends on the media type. You should
# choose how to display the content based on the data['type'] value and
# the oEmbed spec ( http://oembed.com/ ).
if data['type'] == 'video':
    print data['html']

# and it goes... Someday we will provide default renderes for each media
# type.

Addition of new providers

pyoembed tries to cover the major oEmbed providers, and should works for any provider that supports oEmbed auto-discover out-of-the box, however your favorite provider may be unsupported yet! :(

To add it, create a file inside the pyoembed.providers package, based on the following example:

from pyoembed.providers import BaseProvider


class InstagramProvider(BaseProvider):

    # priority of the provider. Increase it if the provider isn't well known
    priority = 10

    # url schemas that are supported by the provider.
    # re.compile'd regex are allowed.
    oembed_schemas = ['http://instagram.com/p/*',
                      'http://instagr.am/p/*']

    # api endpoint that answers to oEmbed requests for the provider.
    oembed_endpoint = 'http://api.instagram.com/oembed'

You will also need to add some test urls of your provider to the integration_test.py file, and run it to see if everything is ok.

If everything works, feel free to send a pull request to add the provider:

https://github.com/rafaelmartins/pyoembed/pulls

That’s it!

Metadata

Release files for pyoembed 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyoembed 0.1.2
File Size Uploaded Provenance Actions
pyoembed-0.1.2.tar.gz 12.5 kB Without provenance Details for pyoembed-0.1.2.tar.gz

Release files / pyoembed-0.1.2.tar.gz

Download URL pyoembed-0.1.2.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0f755c8308039f1e49238e95ea94ef16aa08add9f32075ba13ab9b65f32ff582
BLAKE2b-256 checksum
How to use checksums
32117b9549660ae130668cabc886e4012572745508d381cd0005239b082129a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyoembed 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page