- self.seen[feed_id] = [post.id for post in parsed_feed.entries]
- return
-
- for post in parsed_feed.entries:
- if post.id not in self.seen.get(feed_id):
- self.seen[feed_id].append(post.id)
- self.bot.log.info(post.title)
-
- body = '%(title)s %(link)s' % post
- text.append(body)
-
- xpost = dict(**post)
- xpost['title'] = html_escape(xpost.get('title', 'n/a'))
- xbody = '<a href="%(link)s">%(title)s</a>' % xpost
- xhtml.append(xbody)
-
+ self.seen[feed_id] = {p.id for p in parsed_feed.entries}
+ #return
+
+ # Detecting new post
+ entries = {p.id for p in parsed_feed.entries}
+ new_entries = [p for p in parsed_feed.entries
+ if p.id in entries - self.seen.get(feed_id)]
+ for post in new_entries:
+ self.bot.log.info(post.title)
+
+ body = '%(title)s %(link)s' % post
+ text.append(body)
+
+ xpost = dict(**post)
+ xpost['title'] = html_escape(xpost.get('title', 'n/a'))
+ xbody = '<a href="%(link)s">%(title)s</a>' % xpost
+ xhtml.append(xbody)
+ # Updating self.seen
+ self.seen[feed_id] = entries