Mercurial > hg > Feedworm
comparison backend/AbstractFeedUpdater.py @ 206:f74fe7cb5091
when updating feeds, only ever create new Feed objects for entries that are younger than the current expire date. This ensures that we do not see old, read, expired entries again
author | dirk |
---|---|
date | Sat, 02 Jun 2012 04:30:04 +0200 |
parents | e604c32f67aa |
children | 524cbf9e413c |
comparison
equal
deleted
inserted
replaced
205:adf7f617bda9 | 206:f74fe7cb5091 |
---|---|
1 | 1 |
2 from datetime import datetime | 2 from datetime import datetime |
3 from urllib2 import ProxyHandler | |
4 import AbstractBackend | |
3 import feedparser | 5 import feedparser |
4 import logging | 6 import logging |
5 from urllib2 import ProxyHandler | |
6 | 7 |
7 STATUS_ERROR = 400 | 8 STATUS_ERROR = 400 |
8 log = logging.getLogger("FeedUpdater") | 9 log = logging.getLogger("FeedUpdater") |
9 | 10 |
10 class AbstractFeedUpdater(object): | 11 class AbstractFeedUpdater(object): |
40 return result | 41 return result |
41 | 42 |
42 def _processEntries(self, feedDict): | 43 def _processEntries(self, feedDict): |
43 for entry in feedDict.entries: | 44 for entry in feedDict.entries: |
44 self._normalize(entry) | 45 self._normalize(entry) |
45 self._processEntry(entry) | 46 if not self._isExpired(entry): |
47 self._processEntry(entry) | |
46 self._incrementFeedUpdateDate() | 48 self._incrementFeedUpdateDate() |
47 | 49 |
48 def _normalize(self, entry): | 50 def _normalize(self, entry): |
49 self._normalizeId(entry) | 51 self._normalizeId(entry) |
50 self._normalizePublishedDate(entry) | 52 self._normalizePublishedDate(entry) |
72 if hasattr(entry, "content"): | 74 if hasattr(entry, "content"): |
73 entry.summary = entry.content[0].value | 75 entry.summary = entry.content[0].value |
74 else: | 76 else: |
75 entry.summary = "" | 77 entry.summary = "" |
76 | 78 |
79 def _isExpired(self, entry): | |
80 expireDate = AbstractBackend.calculateExpireDate(self.preferences) | |
81 return entry.updated_parsed < expireDate | |
82 | |
77 def _processEntry(self, entry): | 83 def _processEntry(self, entry): |
78 raise Exception("_processEntry is abstract, subclasses must override") | 84 raise Exception("_processEntry is abstract, subclasses must override") |
79 | 85 |
80 def _incrementFeedUpdateDate(self): | 86 def _incrementFeedUpdateDate(self): |
81 raise Exception("_incrementNextUpdateDate is abstract, subclasses must override") | 87 raise Exception("_incrementNextUpdateDate is abstract, subclasses must override") |