Mercurial > hg > Feedworm
diff backend/couchdb/FeedUpdater.py @ 161:2940e74c9663
Creating a feed via the GUI works now.
author | dirk |
---|---|
date | Mon, 29 Aug 2011 03:08:05 +0200 |
parents | b290e29a94b5 |
children | 04c3b9796b89 |
line wrap: on
line diff
--- a/backend/couchdb/FeedUpdater.py Mon Aug 29 03:07:50 2011 +0200 +++ b/backend/couchdb/FeedUpdater.py Mon Aug 29 03:08:05 2011 +0200 @@ -1,11 +1,24 @@ +from Feed import Feed from FeedEntry import FeedEntry from backend.AbstractFeedUpdater import AbstractFeedUpdater import logging +import feedparser log = logging.getLogger("FeedUpdater") class FeedUpdater(AbstractFeedUpdater): + @staticmethod + def createFeed(url, database): + feedDict = feedparser.parse(url) + if feedDict.has_key("title"): + title = feedDict["feed"].title + else: + title = url + feed = Feed.create(url, title) + feed.store(database) + FeedUpdater(feed, database).update(feedDict) + def __init__(self, feed, database): AbstractFeedUpdater.__init__(self, feed) self.database = database