From 44707374c08606b848b628945a8382f3000fc1ed Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 14 Sep 2014 10:06:45 +0000 Subject: [PATCH] RSS: Fix support of feeds that do no have guid fields. Closes GH845. --- plugins/RSS/plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 840671a75..deaf308f0 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -286,13 +286,17 @@ class RSS(callbacks.Plugin): self.update_feed_if_needed(feed) def get_new_entries(self, feed): + # http://validator.w3.org/feed/docs/rss2.html#hrelementsOfLtitemgt + get_id = lambda entry: entry.id if hasattr(entry, 'id') else ( + entry.title if hasattr(entry, 'title') else entry.description) + with feed.lock: entries = feed.entries new_entries = [entry for entry in entries - if entry.id not in feed.announced_entries] + if get_id(entry) not in feed.announced_entries] if not new_entries: return [] - feed.announced_entries |= set(entry.id for entry in new_entries) + feed.announced_entries |= set(get_id(entry) for entry in new_entries) # We keep a little more because we don't want to re-announce # oldest entries if one of the newest gets removed. feed.announced_entries.truncate(10*len(entries))