From: Brett Parker Date: Fri, 21 Dec 2007 21:29:17 +0000 (+0000) Subject: * be slightly more forgiving on connection resets X-Git-Url: https://git.sommitrealweird.co.uk/rss2maildir.git/commitdiff_plain/8b1be1378edae49d57890b35bda0d18b399258fd?hp=03e4620598f673f0148f8dd4041576fb8947469b * be slightly more forgiving on connection resets * if there's no date in the feed, use todays date/time --- diff --git a/rss2maildir.py b/rss2maildir.py index 4402c43..d8cd3e4 100755 --- a/rss2maildir.py +++ b/rss2maildir.py @@ -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\" " %(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")