diff options
Diffstat (limited to 'maildir2rss.py')
-rw-r--r-- | maildir2rss.py | 37 |
1 files changed, 37 insertions, 0 deletions
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) |