micawber: A Python Library for Extracting Rich Content from URLs
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
micawber is a lightweight Python library designed to extract rich content from various URLs, leveraging the oEmbed standard. It provides methods to retrieve metadata and embed codes for services like YouTube and Flickr. This library simplifies the process of displaying embedded media and rich previews in web applications.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
micawber is a lightweight Python library developed by coleifer designed to simplify the extraction of rich content from various URLs. It leverages the oEmbed standard to retrieve metadata and embed codes for links to services like YouTube, Flickr, and many others. This makes it ideal for applications that need to display embedded media or rich previews from external sources.
Installation
To get started with micawber, you can easily install it using pip:
pip install micawber
Examples
The library provides straightforward methods for requesting oEmbed data and parsing text or HTML to automatically embed content.
Here's a quick example of how to use micawber to retrieve information for a YouTube video:
import micawber
# Load up rules for some default providers, such as YouTube and Flickr
providers = micawber.bootstrap_basic()
# Request data for a specific URL
data = providers.request('http://www.youtube.com/watch?v=54XHDUOHuzU')
print(data)
# Expected output (dictionary containing video metadata and HTML embed code):
# {
# 'author_name': 'pascalbrax',
# 'author_url': 'http://www.youtube.com/user/pascalbrax',
# 'height': 344,
# 'html': '',
# 'provider_name': 'YouTube',
# 'provider_url': 'http://www.youtube.com/',
# 'title': 'Future Crew - Second Reality demo - HD',
# 'type': 'video',
# 'thumbnail_height': 360,
# 'thumbnail_url': 'http://i2.ytimg.com/vi/54XHDUOHuzU/hqdefault.jpg',
# 'thumbnail_width': 480,
# 'url': 'http://www.youtube.com/watch?v=54XHDUOHuzU',
# 'width': 459,
# 'version': '1.0',
# }
You can also parse text or HTML to automatically replace URLs with their embedded content:
# Parse text
parsed_text = providers.parse_text('this is a test:\nhttp://www.youtube.com/watch?v=54XHDUOHuzU')
print(parsed_text)
# Expected output:
# this is a test:
#
# Parse HTML
parsed_html = providers.parse_html('http://www.youtube.com/watch?v=54XHDUOHuzU
')
print(parsed_html)
# Expected output:
#
Why Use micawber?
micawber simplifies the complex task of integrating rich media from external services into your applications. By abstracting the oEmbed protocol, it allows developers to quickly add features like video embedding, image previews, and rich link summaries with minimal code. Its ability to parse both plain text and HTML makes it versatile for various content management and display scenarios.
Links
For more detailed information, documentation, and to contribute, visit the official GitHub repository:
Related repositories
Similar repositories that may be relevant next.
Source repository
Open the original repository on GitHub.