diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-01-20 09:54:33 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-01-20 09:54:33 +0100 |
commit | f609f6fd98f447bdb9fc3cf06b03a2aa177df4b5 (patch) | |
tree | 2e8e4abe3f32d3e0bf45283fa72bf161c8c83784 | |
parent | Added some tricks to get all posts of a blog. (diff) | |
download | newspipe-f609f6fd98f447bdb9fc3cf06b03a2aa177df4b5.tar.gz newspipe-f609f6fd98f447bdb9fc3cf06b03a2aa177df4b5.tar.bz2 newspipe-f609f6fd98f447bdb9fc3cf06b03a2aa177df4b5.zip |
Test if the MongoDB collection exist before the creation.
-rwxr-xr-x | source/feedgetter.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source/feedgetter.py b/source/feedgetter.py index b6b5e8b6..82ad2a0f 100755 --- a/source/feedgetter.py +++ b/source/feedgetter.py @@ -108,16 +108,16 @@ class FeedGetter(object): sha1_hash.update(feed_link.encode('utf-8')) feed_id = sha1_hash.hexdigest() - collection_dic = {"feed_id": feed_id, \ - "type": 0, \ - "feed_image": feed_image, \ - "feed_title": utils.clear_string(a_feed.feed.title), \ - "feed_link": feed_link, \ - "site_link": a_feed.feed.link, \ - "mail": False \ - } - - self.articles.add_collection(collection_dic) + if None == self.articles.get_feed(feed_id): + collection_dic = {"feed_id": feed_id, \ + "type": 0, \ + "feed_image": feed_image, \ + "feed_title": utils.clear_string(a_feed.feed.title), \ + "feed_link": feed_link, \ + "site_link": a_feed.feed.link, \ + "mail": False \ + } + self.articles.add_collection(collection_dic) articles = [] for article in a_feed['entries']: |