Command line Bloglines Notifier in Python

Another stupid script that I wrote as my latest attempt in procrastination. This Python script basically queries Bloglines for the number of unread items you have. A bit like notifiers that are already available on Windows and Mac, except on command line, where ever real man works :)

Interestingly Bloglines does not require password to get that information. You can download the Python source code here:

Or syntax highlighted source:

#!/usr/bin/env python

import re
import urllib

BLOGLINES_URL = "http://rpc.bloglines.com/update?ver=1&user=%s"

def check(email):
    data = urllib.urlopen(BLOGLINES_URL % urllib.quote(email))
    data = re.match(r'^|([-d]+)|(.*?)|', data.read())
    if data is not None:
        count = int(data.group(1))
        if count > 1:
            print '%s: %d new items.' % (email, count)
        elif count == 1:
            print '%s: 1 new item.' % email
        elif count == 0:
            print '%s: no new item.' % email
        else:
            print '%s: invalid email address.'

if __name__ == '__main__':
    import os
    import sys
    if len(sys.argv) == 1:
        print 'Usage: %s [email address] [email addresses] ...' % 
            os.path.basename(sys.argv[0])
    else:
        for email in sys.argv[1:]:
            check(email)

Updated 9 Oct 2004: URL has been changed slightly to match the one given by Bloglines notifier API.

Related

  • Bloglines2HTML - a Python script that downloads Bloglines feeds and convert them into static HTML.