Mercurial > hg > Feedworm
diff FeedUpdater.py @ 35:aaec263f07ca
Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 03:07:59 +0200 |
parents | 72dfae865899 |
children | 0604e374c1d6 |
line wrap: on
line diff
--- a/FeedUpdater.py Wed May 05 02:14:05 2010 +0200 +++ b/FeedUpdater.py Wed May 05 03:07:59 2010 +0200 @@ -9,7 +9,7 @@ log = logging.getLogger("FeedUpdater") def updateAllFeeds(session): - allFeeds = session.query(Feed) + allFeeds = findFeedsToUpdate(session) for feed in allFeeds: try: FeedUpdater(session, feed).update() @@ -17,6 +17,9 @@ log.warn("problems while updating feed " + feed.rss_url) session.commit() +def findFeedsToUpdate(session): + return session.query(Feed).filter(Feed.next_update < datetime.now()) + def createNewFeed(url, session): result = feedparser.parse(url) title = result["feed"].title @@ -37,6 +40,7 @@ result = self.getFeed() for entry in result.entries: self.processEntry(entry) + self.feed.incrementNextUpdateDate() def getFeed(self): result = feedparser.parse(self.feed.rss_url)