X-Git-Url: https://projects.mako.cc/source/iron-blogger/blobdiff_plain/1a91b66e5b75c8dd14e6c16ea10a70baf6bf1ac3..bf1fb66fb40e3ad7a6bb8a3c361aa3318cfc0331:/report.py diff --git a/report.py b/report.py old mode 100644 new mode 100755 index 3959889..998a1cc --- a/report.py +++ b/report.py @@ -1,3 +1,4 @@ +#!/usr/bin/python import yaml import feedparser import datetime @@ -20,9 +21,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) @@ -49,5 +56,5 @@ for (username, u) in users.items(): for (i, w) in enumerate(weeks): print " [%d]: %s" % (i, w) -with open('report.yml', 'w') as f: +with open('out/report.yml', 'w') as f: yaml.safe_dump(log, f)