config and feed: Added trust-link preference
authorGeorge Saunders <georgesaunders@gmail.com>
Fri, 22 Mar 2013 04:49:27 +0000 (04:49 +0000)
committerGeorge Saunders <georgesaunders@gmail.com>
Sat, 21 Dec 2013 18:01:28 +0000 (18:01 +0000)
The trust-link preference allows the user to ignore feed
entries that repeat a previously seen link URL.

Signed-off-by: George Saunders <georgesaunders@gmail.com>
rss2email/config.py
rss2email/feed.py

index 6b5155fa8056d7ed9b888e9b79fe7fa2f1d2add5..1f9ebbe685705e5212f99d97f803254b77f4c30f 100644 (file)
@@ -107,6 +107,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # True: Receive one email per post.
         # False: Receive an email every time a post changes.
         ('trust-guid', str(True)),
+        # True: Receive one email per unique link url.
+        # False: Defer to trust-guid preference.
+        ('trust-link', str(False)),
         # To most correctly encode emails with international
         # characters, we iterate through the list below and use the
         # first character set that works.
index a11f6c7bfb2edb5042bd2eae42bf7b107546f342..ef4d77058dde724d744cb52bb95176eecd4da8b3 100644 (file)
@@ -180,6 +180,7 @@ class Feed (object):
         'active',
         'date_header',
         'trust_guid',
+        'trust_link',
         'html_mail',
         'use_css',
         'unicode_snob',
@@ -498,6 +499,8 @@ class Feed (object):
 
     def _get_entry_id(self, entry):
         """Get best ID from an entry."""
+        if self.trust_link:
+            return entry.get('link', None)
         if self.trust_guid:
             if getattr(entry, 'id', None):
                 # Newer versions of feedparser could return a dictionary