Improve the logic for choosing a link from a feed.
[iron-blogger] / report.py
index 2c9a97e584bee6c6bacfa2de6cb87505018b8d84..e782c499841ccee207e13313a1931ca4d51bb229 100644 (file)
--- 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)

Benjamin Mako Hill || Want to submit a patch?