feed: fix Feed._get_entry_content unpacking in Feed._get_entry_title
authorW. Trevor King <wking@tremily.us>
Mon, 10 Dec 2012 23:23:51 +0000 (18:23 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 11 Dec 2012 01:05:57 +0000 (20:05 -0500)
_get_entry_content returns a single dict, but _get_entry_id had been
unpacking it as if it was an object with a `content` attribute.

Also convert HTML to text before extracting the title, to avoid things
like `<p>In the beginning...` in the title.

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/feed.py

index d7bd74fb4e3675df5d2cb1bfefebb56a57904e75..30a7667106817dc3ede7c2070d22a4f2ea062a1e 100644 (file)
@@ -448,7 +448,11 @@ class Feed (object):
             if 'html' in entry.title_detail.type:
                 title = _html2text.html2text(title)
         else:
-            title = self._get_entry_content(entry).content[:70]
+            content = self._get_entry_content(entry)
+            value = content['value']
+            if content['type'] in ('text/html', 'application/xhtml+xml'):
+                value = _html2text.html2text(value)
+            title = value[:70]
         title = title.replace('\n', ' ').strip()
         return title