diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-11-01 15:33:36 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-11-01 15:33:36 +0100 |
commit | 6cc4bfdf8d67029b5038693dc99c27e669d0234c (patch) | |
tree | 8f379e249007cd753d291b44013b581b13881c6b /pyaggr3g470r/feedgetter.py | |
parent | Added users management. (diff) | |
download | newspipe-6cc4bfdf8d67029b5038693dc99c27e669d0234c.tar.gz newspipe-6cc4bfdf8d67029b5038693dc99c27e669d0234c.tar.bz2 newspipe-6cc4bfdf8d67029b5038693dc99c27e669d0234c.zip |
It is now possible to add a feed via a form for different users.
Diffstat (limited to 'pyaggr3g470r/feedgetter.py')
-rw-r--r-- | pyaggr3g470r/feedgetter.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py index bae0cb8b..2b0c08f9 100644 --- a/pyaggr3g470r/feedgetter.py +++ b/pyaggr3g470r/feedgetter.py @@ -50,23 +50,23 @@ class FeedGetter(object): This class uses feedparser module from Mark Pilgrim. For each feed a new thread is launched. """ - def __init__(self): + def __init__(self, email): """ Initializes the database connection. """ #feedparser.USER_AGENT = conf.USER_AGENT feedparser.USER_AGENT = "pyAggr3g470r" + self.user = models.User.objects(email=email).first() def retrieve_feed(self): """ Parse the file 'feeds.lst' and launch a thread for each RSS feed. """ - feeds = models.Feed.objects() - for feed in feeds: + for feed in self.user.feeds: try: # launch a new thread for the RSS feed thread = threading.Thread(None, self.process, \ - None, (feed,)) + None, (feed, )) thread.start() list_of_threads.append(thread) except: @@ -88,8 +88,7 @@ class FeedGetter(object): articles = [] for article in a_feed['entries']: - exist = models.Article.objects(link=article.link).first() - if exist != None: + if article.link in [farticle.link for farticle in feed.articles]: continue description = "" @@ -137,7 +136,8 @@ class FeedGetter(object): """ feed.articles.extend(articles) feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True) - feed.save() + #feed.save() + self.user.save() if __name__ == "__main__": |