aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rwxr-xr-xsource/feedgetter.py4
-rw-r--r--source/mongodb.py5
-rwxr-xr-xsource/utils.py8
3 files changed, 12 insertions, 5 deletions
diff --git a/source/feedgetter.py b/source/feedgetter.py
index 8b1c8401..84dd2f47 100755
--- a/source/feedgetter.py
+++ b/source/feedgetter.py
@@ -155,8 +155,8 @@ class FeedGetter(object):
articles.append(article)
- if feed["mail"]:
- # send new articles by e-mail if desired.
+ if feed["mail"] and self.articles.get_articles(feed_id, article_id) == False:
+ # if subscribed to the feed AND if article not already in the database
threading.Thread(None, utils.send_mail, None, (conf.mail_from, conf.mail_to, \
a_feed.feed.title, \
article_title, description)).start()
diff --git a/source/mongodb.py b/source/mongodb.py
index 7879adee..93894154 100644
--- a/source/mongodb.py
+++ b/source/mongodb.py
@@ -131,7 +131,10 @@ class Articles(object):
elif feed_id != None and article_id != None:
# Return a precise article.
collection = self.db[str(feed_id)]
- return next(collection.find({"article_id":article_id}))
+ try:
+ return next(collection.find({"article_id":article_id}))
+ except:
+ return False
def get_favorites(self, feed_id=None):
"""
diff --git a/source/utils.py b/source/utils.py
index 4ceb3026..f2756286 100755
--- a/source/utils.py
+++ b/source/utils.py
@@ -168,8 +168,12 @@ def send_mail(mfrom, mto, feed_title, article_title, description):
msg.attach(part2)
# Send the message via local SMTP server.
- s = smtplib.SMTP(conf.smtp_server)
- s.login(conf.username, conf.password)
+ try:
+ s = smtplib.SMTP(conf.smtp_server)
+ s.login(conf.username, conf.password)
+ except:
+ print("smtp error")
+ return
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(mfrom, mto, msg.as_string())
bgstack15