From 6e33a67a8cb5011081e4dfb78b3082dd86ce8886 Mon Sep 17 00:00:00 2001 From: yvesf Date: Sat, 20 Feb 2010 22:50:36 +0100 Subject: mhonarc, maildir 2 rss --- maildir2rss.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 maildir2rss.py (limited to 'maildir2rss.py') diff --git a/maildir2rss.py b/maildir2rss.py new file mode 100644 index 0000000..563a48f --- /dev/null +++ b/maildir2rss.py @@ -0,0 +1,37 @@ +import datetime +import PyRSS2Gen +from mailbox import Maildir +import os,sys + +maildir=Maildir(os.path.dirname(os.path.abspath(__file__)) + "/Maildir") + +items=[] +for key in maildir.keys(): + msg = maildir[key] + try: + subject = msg['subject'] + author=msg['from'] + msg.rewindbody() + description = msg.fp.read() + rfcdate = msg.getdate('date') + date=datetime.datetime(*rfcdate[:-2]) + item=PyRSS2Gen.RSSItem( + title=subject, + author=author, + link="http://xapek.org", + description=description, + pubDate=date + ) + items.append(item) + sys.stderr.write( "processed %s\n" % key) + except Exception,e: + sys.stderr.write("skip %s: %s\n" % (key,str(e))) + +rss = PyRSS2Gen.RSS2( + title = "Spamfeed", + link = "http://www.xapek.org/~yvesf/spam", + description = "Spam spam spam", + lastBuildDate = datetime.datetime.now(), + items=items +) +rss.write_xml(sys.stdout) -- cgit v1.2.1