Apr 28 2004

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.

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

2 Comments

  1. a l on 28 Apr 2004 at 2:08 pm #

    hi, just wanted to let u know that i inserted the tag you mentioned in my other blogs and it worked! thanks!

  2. scotty on 28 Apr 2004 at 2:25 pm #

    :)

    I was having fun ripping off the banner ads on the free services, and I am pretty sure that this kind of HOWTO must be documented everywhere. Not really sure whether it is a Christian thing to do.

    Well. Back to the Bloglines notifier. Now I just need to add that to my Jabber bot so I can get instant message whenever there is a new item. Yup. A new idea for procrastination…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>