aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/feedgetter.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-11-10 18:29:53 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-11-10 18:29:53 +0100
commit50ce677513a06e98a48e236ff008d2015a2c6484 (patch)
tree1f9edcfb9629ba9544fdab38a1a262a911c1c033 /pyaggr3g470r/feedgetter.py
parentRemoved code related to QR Code generation. (diff)
downloadnewspipe-50ce677513a06e98a48e236ff008d2015a2c6484.tar.gz
newspipe-50ce677513a06e98a48e236ff008d2015a2c6484.tar.bz2
newspipe-50ce677513a06e98a48e236ff008d2015a2c6484.zip
Email notification.
Diffstat (limited to 'pyaggr3g470r/feedgetter.py')
-rw-r--r--pyaggr3g470r/feedgetter.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index 421ce893..850f4449 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -39,6 +39,9 @@ import conf
import search
import utils
+from flask.ext.mail import Message
+from pyaggr3g470r import app, mail
+
#import log
#pyaggr3g470r_log = log.Log()
@@ -89,6 +92,7 @@ class FeedGetter(object):
for article in a_feed['entries']:
if models.Article.objects(link=article.link).first() != None:
+ # if article already in the database continue with the next article
continue
description = ""
@@ -119,21 +123,23 @@ class FeedGetter(object):
articles.append(article)
"""
- if self.articles.get_articles(feed_id, article_id) == []:
- # add the article to the Whoosh index
- try:
- search.add_to_index([article], feed)
- except:
- print("Whoosh error.")
- #pyaggr3g470r_log.error("Whoosh error.")
- continue
-
- if conf.MAIL_ENABLED and feed["mail"]:
- # if subscribed to the feed
- threading.Thread(None, utils.send_mail, None, (conf.mail_from, conf.mail_to, \
- a_feed.feed.title, \
- article_title, description)).start()
- """
+ # add the article to the Whoosh index
+ try:
+ search.add_to_index([article], feed)
+ except:
+ print("Whoosh error.")
+ #pyaggr3g470r_log.error("Whoosh error.")
+ continue"""
+
+ if conf.MAIL_ENABLED and feed.email_notification:
+ # if subscribed to the feed
+ with app.app_context():
+ msg = Message('[pyAggr3g470r] ' + feed.title + ' : ' + article.title, \
+ sender = conf.MAIL_FROM, recipients = [conf.MAIL_TO])
+ msg.body = utils.clear_string(description)
+ msg.html = description
+ mail.send(msg)
+
feed.articles.extend(articles)
feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True)
#feed.save()
bgstack15