Archive for August, 2011

TT-RSS notification of unread articles

Thursday, August 18th, 2011

I use Tiny Tiny RSS as an alternative to Google Reader. It is an open source web based RSS feed reader.

I created a little Python script that shows a notification on the Mac OS X desktop in case I have unread articles. It is called from crontab. Every ten minutes, the script checks for unread messages and shows a message via Growl:


  • Python, which is probably already installed on most Linuxes and Mac OS X. It uses the json, urllib2 and os modules
  • Growl, install also growlnotify from the Extras
  • And Tiny Tiny RSS, tested with version 1.5.5

For Linux, libnotify provides the a command line interface for displaying notifications: notify-send. You can use that instead of growlnotify for showing the number of unread articles. In Ubuntu, notify-send is found in package libnotify-bin.


import json
import urllib2
import os
class request:
class ttrss:
	session_id = ''
	def __init__(self, url):
		self.baseurl = url
	def getResponse(self, call):
		call['sid'] = self.session_id
		httpres = urllib2.urlopen(self.baseurl, json.dumps(call))
		ttrssresponse = json.load(httpres)
		return ttrssresponse
	def login(self, username, password):
		req = { 'op': 'login', 'user': username, 'password':password }
		res = self.getResponse(req)
		self.session_id = res['content']['session_id']
	def getUnreadCount(self):
		req = { 'op': 'getUnread'}
		res = self.getResponse(req)
		return int( res['content']['unread'] )
t = ttrss('')
# Username, password
unread = t.getUnreadCount()
if (unread > 0):
	cmd = "/usr/local/bin/growlnotify -a Mail -m '" + str( unread ) + " unread article(s)' --url Tiny Tiny RSS"
	os.system( cmd )