TT-RSS notification of unread articles

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:

Requirements:

  • 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.

Download

#!/usr/bin/python
import json
import urllib2
import os
 
class request:
	pass
 
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'] )
 
# TT-RSS API URL
t = ttrss('http://example.org/tt-rss/api/')
# Username, password
t.login('yourusername','yourpassword')
unread = t.getUnreadCount()
if (unread > 0):
	cmd = "/usr/local/bin/growlnotify -a Mail -m '" + str( unread ) + " unread article(s)' --url https://rutgerwessels.nl/feeds Tiny Tiny RSS"
	os.system( cmd )

6 Responses to “TT-RSS notification of unread articles”

  1. [...] Get TTRSS Notifications in Growl (OS X) or libnotify (Linux) [...]

  2. on her creativity cap when she starts designing a range of handbags for her boyfriend?? fashion line. Justin Timberlake has founded the William Rast Company along with

  3. Tim Kramer says:

    Works nicely with notify-send on Ubuntu 12.10. The one issue that I encountered was of my own doing (not using the standard URL). Once I’d noticed that, it worked without any additional modification. Thanks!

  4. Martin says:

    Hi,

    thank you for your Script – i changed it to work with terminal-notifier:

    cmd = “/usr/local/bin/terminal-notifier.app/Contents/MacOS/terminal-notifier -title ‘Tiny Tiny RSS’ -message ‘” + str( unread ) + ” unread article(s) Tiny Tiny RSS’ -open http://via.selfip.org/rss

    Great Work!

  5. Alastair says:

    Alastair

    TT-RSS notification of unread articles « Rutger’s Weblog

Leave a Reply