Wednesday, August 28, 2013

Micawber gets rich content from URLs


By Vasudev Ram



micawber is a Python library that enables you to "fetch rich content from URLs" of videos, music, etc. I guess micawber is named after the character Micawber in the novel "David Copperfield" by Charles Dickens.

coleifer/micawber on GitHub

Read the micawber docs

I wrote a small test program to try out micawber, by modifying one of the basic examples of its use. It fetches some of the data about 3 YouTube videos: Andres Segovia playing 'Asturias', Guido van Rossum's talk - 'In Python We Trust', and Luisa Fernandez singing 'Granada'.

Here is the program:
# test_micawber.py

import micawber

# load up rules for some default providers, such as youtube and flickr
providers = micawber.bootstrap_basic()

# Fetch the data for 3 video URLs
for url in [ 'http://www.youtube.com/watch?v=9efHwnFAkuA',
    'http://www.youtube.com/watch?v=mWB3oh1GPdo',
    'http://www.youtube.com/watch?v=UYGc9joeAD0' ]:
    
    retval = providers.request(url)
    for key in ['type', 'title', 'url', 'author_name', 
    'author_url', 'provider_name', 'provider_url', 'height',
    'width', 'thumbnail_url']:
        print key, ":", retval[key]

    print

# EOF
You can run it like this:
python test_micawber.py
And here is its output:
type : video
title : Andres Segovia - Asturias
url : http://www.youtube.com/watch?v=9efHwnFAkuA
author_name : ByTheSPiRiTs
author_url : http://www.youtube.com/user/ByTheSPiRiTs
provider_name : YouTube
provider_url : http://www.youtube.com/
height : 344
width : 459
thumbnail_url : http://i1.ytimg.com/vi/9efHwnFAkuA/hqdefault.jpg

type : video
title : In Python We Trust
url : http://www.youtube.com/watch?v=mWB3oh1GPdo
author_name : OreillyMedia
author_url : http://www.youtube.com/user/OreillyMedia
provider_name : YouTube
provider_url : http://www.youtube.com/
height : 270
width : 480
thumbnail_url : http://i1.ytimg.com/vi/mWB3oh1GPdo/hqdefault.jpg

type : video
title : Luisa Fernandez -  Granada
url : http://www.youtube.com/watch?v=UYGc9joeAD0
author_name : Dany Massart
author_url : http://www.youtube.com/user/DJCOOLDANY
provider_name : YouTube
provider_url : http://www.youtube.com/
height : 344
width : 459
thumbnail_url : http://i1.ytimg.com/vi/UYGc9joeAD0/hqdefault.jpg

- Vasudev Ram - Dancing Bison Enterprises

Contact me

No comments: