diff options
author | Magnus Hagander | 2008-11-03 14:06:45 +0000 |
---|---|---|
committer | Magnus Hagander | 2008-11-03 14:06:45 +0000 |
commit | b303aadba57c7b6e6710dad6e20b47dd644a06f4 (patch) | |
tree | 0ae150de843f6615d823f3a08d09a28f98adeee0 | |
parent | 66dec2b79bd6eaebc31c752ddd5cbc616f1b1600 (diff) |
Re-order the way we try to get the text from a blog post. This
should favour the longer posts available in some feeds (and
we'll just cut them off before displaying them if required)
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2259 8f5c7a92-453e-0410-a47f-ad33c8a6b003
-rwxr-xr-x | planet/aggregator.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/planet/aggregator.py b/planet/aggregator.py index b73c467b..dba6d176 100755 --- a/planet/aggregator.py +++ b/planet/aggregator.py @@ -44,10 +44,20 @@ class Aggregator: return for entry in feed.entries: - if entry.has_key('summary'): - txt = entry.summary - else: + # Grab the entry. At least atom feeds from wordpress store what we + # want in entry.content[0].value and *also* has a summary that's + # much shorter. Other blog software store what we want in the summary + # attribute. So let's just try one after another until we hit something. + try: txt = entry.content[0].value + except: + txt = '' + if txt == '' and entry.has_key('summary'): + txt = entry.summary + if txt == '': + print "Failed to get text for entry at %s" % entry.link + continue + if entry.has_key('guidislink'): guidisperma = entry.guidislink else: |