Permalink
Browse files

New way to figure out which text from the RSS flow to include in the …

…blog:

try every option we know about, and pick the longest available text.
  • Loading branch information...
mhagander committed Aug 3, 2009
1 parent f1d609d commit 649a5c79c25b93282e629059a7e35f85ae46e861
Showing with 11 additions and 6 deletions.
  1. +11 −6 aggregator.py
View
@@ -69,14 +69,19 @@ def ParseFeed(self, feedinfo):
# 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.
+ # much shorter.
+ # We therefor check all available texts, and just pick the one that
+ # is longest.
+ txtalts = []
try:
- txt = entry.content[0].value
+ txtalts.append(entry.content[0].value)
except:
- txt = ''
- if txt == '' and entry.has_key('summary'):
- txt = entry.summary
+ pass
+ if entry.has_key('summary'):
+ txtalts.append(entry.summary)
+
+ # Select the longest text
+ txt = max(txtalts, key=len)
if txt == '':
# Not a critical error, we just ignore empty posts
print "Failed to get text for entry at %s" % entry.link

0 comments on commit 649a5c7

Please sign in to comment.