- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- # Copyright (C) 2008 Steven
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- # Blog: http://stebalien.com
- import feedparser
- import textwrap
- import time
- import unicodedata
- ### SETTINGS ###
- # Username (lowercase)
- USER = "<username>"
- # Width in charictars of output
- WIDTH = 50
- # Number of posts to display
- POSTS = 10
- ################
- def formatPost(string):
- string = unicodedata.normalize('NFKD', string).encode('ascii','ignore')
- parts = string.partition(':')
- return parts[0] + parts[1] \
- + "\n" + wrapper.fill('\n' \
- + parts[2]) \
- + "\n\n"
- wrapper = textwrap.TextWrapper()
- wrapper.subsequent_indent = ' '
- wrapper.initial_indent = ' '
- wrapper.width = WIDTH
- # Get and display feed
- all_feed = feedparser.parse("http://identi.ca/" + USER + "/all/rss")
- reply_feed = feedparser.parse("http://identi.ca/" + USER + "/replies/rss")
- n = 0
- i = 0
- while ((i+n) < POSTS):
- while (reply_feed.entries[n].updated_parsed > all_feed.entries[i].updated_parsed):
- print "> " + formatPost(reply_feed.entries[n].title)
- n=n+1
- print " " + formatPost(all_feed.entries[i].title)
- i=i+1
