Paste2 Logo
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Copyright (C) 2008 Steven
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. # Blog: http://stebalien.com
  20.  
  21. import feedparser
  22. import textwrap
  23. import time
  24. import unicodedata
  25.  
  26. ### SETTINGS ###
  27. # Username (lowercase)
  28. USER = "<username>"
  29. # Width in charictars of output
  30. WIDTH = 50
  31. # Number of posts to display
  32. POSTS = 10
  33. ################
  34.  
  35. def formatPost(string):
  36.         string = unicodedata.normalize('NFKD', string).encode('ascii','ignore')
  37.         parts = string.partition(':')
  38.         return parts[0] + parts[1] \
  39.         + "\n" + wrapper.fill('\n' \
  40.         + parts[2]) \
  41.         + "\n\n"
  42.        
  43. wrapper = textwrap.TextWrapper()
  44. wrapper.subsequent_indent = '     '
  45. wrapper.initial_indent = '   '
  46. wrapper.width = WIDTH
  47. # Get and display feed
  48. all_feed = feedparser.parse("http://identi.ca/" + USER + "/all/rss")
  49. reply_feed = feedparser.parse("http://identi.ca/" + USER + "/replies/rss")
  50.  
  51. n = 0
  52. i = 0
  53.  
  54. while ((i+n) < POSTS):
  55.         while (reply_feed.entries[n].updated_parsed > all_feed.entries[i].updated_parsed):
  56.                 print "> " + formatPost(reply_feed.entries[n].title)
  57.                 n=n+1
  58.         print "  " + formatPost(all_feed.entries[i].title)
  59.         i=i+1
  60.  

Parent