From 3580088d8cbe24e93875479786ddcc174dc539ba Mon Sep 17 00:00:00 2001 From: Nelson Elhage Date: Mon, 28 Dec 2009 23:16:55 -0500 Subject: [PATCH] Improve the logic for choosing a link from a feed. --- report.py | 8 +++++++- templates/email.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/report.py b/report.py index 2c9a97e..e782c49 100644 --- a/report.py +++ b/report.py @@ -20,9 +20,15 @@ def get_date(post): return post.updated def get_link(post): + if 'links' in post: + links = dict((l.rel, l) for l in post.links if 'html' in l.type) + if 'self' in links: + return links['self'].href + elif 'alternate' in links: + return links['alternate'].href if 'href' in post: return post.href - return post.links[0]['href'] + return None def parse_feeds(weeks, uri): feed = feedparser.parse(uri) diff --git a/templates/email.txt b/templates/email.txt index 106141c..741e373 100644 --- a/templates/email.txt +++ b/templates/email.txt @@ -1,4 +1,4 @@ -Subject: IRON BLOGGER results for the week of ${week_start.strftime("%F")} +Subject: IRON BLOGGER results for the week beginning ${week_start.strftime("%F")} To: iron-blogger@mit.edu People who posted: -- 2.30.2