Wednesday, October 28, 2009

DIY: Google Mail Notifier

It's quite easy to create your own GMail notifier. Your inbox, gmail or domain,  can be monitored by fetching and parsing an atom feed.

Following code snippet prints new (unread) mail in your inbox:
# -*- coding: utf-8 -*-
import feedparser
import urllib2

# Create http basic auth handler
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('New mail feed', 'https://mail.google.com/',
                          'USERNAME@DOMAIN', 'PASSWORD')

# Open url using the auth handler
opener = urllib2.build_opener(auth_handler)
feed_file = opener.open('https://mail.google.com/mail/feed/atom/')

# Parse feed using feedparser
d = feedparser.parse(feed_file)

# Print mail count and mails
print 'Mail count:', d.feed.fullcount

for entry in d.entries:
        print '----------------------------------------------'
 print 'Author: ', entry.author
 print 'Subject:', entry.title
 print 'Summary:', entry.summary

Just change USERNAME and PASSWORD. You also need to download feedparser which is free to use, or write one yourself.

Have fun!

ELCE 2009 presentations

The presentations from ELCE 2009 are now available from here. Some of the presentations have not been posted yet.

Monday, October 26, 2009

pyshoutcast v0.7.1

pyshoutcast version 0.7.1 has just been released. It implements a Python shoutcast API which makes it possible to list genres, stations, do search, etc, using the shoutcast yellow pages service.

Unfortunately, I just found a forum post stating that Amarok and VLC have removed support for shoutcast due to licensing issues. I'm not sure why because I can't find any info about it, I'll try to find out more details.

Anyway, to try it out you can start a interactive python prompt and paste the following code:
>>> import shoutcast
>>> api = shoutcast.ShoutCast()
>>> api.random()