micawber

0.6.2 · maintenance · verified Fri Apr 17

micawber is a small Python library for extracting rich content (like videos, images, or summaries) from URLs using the oEmbed specification. It includes a set of pre-configured providers for common services like YouTube, Vimeo, and Flickr. The latest version is 0.6.2, released in 2017, and it appears to be in maintenance mode, stable but not actively developed.

Common errors

Warnings

Install

Imports

Quickstart

Initialize micawber with default OEmbed providers and an in-memory cache. Then, use `m.request()` to fetch OEmbed data for a specific URL or `m.parse_text()` to automatically find URLs within text and replace them with embedded content.

import micawber
from micawber.cache import Cache

# Configure Micawber with default providers and an in-memory cache
m = micawber.bootstrap_basic(cache=Cache())

# Example URL (using a real OEmbed example, this is usually a video)
youtube_url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'

# Request OEmbed data for a URL
try:
    response = m.request(youtube_url)
    print(f"Title: {response.get('title')}")
    print(f"Type: {response.get('type')}")
    print(f"HTML: {response.get('html', 'No HTML provided')[:50]}...")
except Exception as e:
    print(f"Error requesting OEmbed data: {e}")

# Alternatively, parse text containing URLs and replace them with rich content
text_with_url = f'Check out this video: {youtube_url} and some other stuff.'
html_output = m.parse_text(text_with_url)
print("\n--- Parsed Text HTML Output ---")
print(html_output[:200] + '...') # Print first 200 chars for brevity

view raw JSON →