]> git.sommitrealweird.co.uk Git - rss2maildir.git/commitdiff
* be slightly more forgiving on connection resets
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Fri, 21 Dec 2007 21:29:17 +0000 (21:29 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Fri, 21 Dec 2007 21:29:17 +0000 (21:29 +0000)
* if there's no date in the feed, use todays date/time

rss2maildir.py

index 4402c43884ae5271a201de8529ebc46271a5fcdc..d8cd3e4b109d4af1035f1ffd3b4d7cd935da721e 100755 (executable)
@@ -299,7 +299,12 @@ def parse_and_deliver(maildir, url, statedir):
     else:
         conn = httplib.HTTPConnection("%s:%s" %(host, port))
         conn.request("GET", path)
-        response = conn.getresponse()
+        response = None
+        try:
+            response = conn.getresponse()
+        except:
+            print "Failed to fetch feed: %s" %(url)
+            return
         headers = response.getheaders()
         feedhandle = response
 
@@ -347,8 +352,13 @@ def parse_and_deliver(maildir, url, statedir):
         msg.add_header("To", "\"%s\" <rss2maildir@localhost>" %(url))
         if prevmessageid:
             msg.add_header("References", prevmessageid)
-        createddate = datetime.datetime(*item["updated_parsed"][0:6]) \
+        createddate = datetime.datetime.now() \
             .strftime("%a, %e %b %Y %T -0000")
+        try:
+            createddate = datetime.datetime(*item["updated_parsed"][0:6]) \
+                .strftime("%a, %e %b %Y %T -0000")
+        except:
+            pass
         msg.add_header("Date", createddate)
         msg.add_header("Subject", item["title"])
         msg.set_default_type("text/plain")