diff options
author | cedricbonhomme <devnull@localhost> | 2010-11-23 11:40:56 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-11-23 11:40:56 +0100 |
commit | 6b4eff20bea59339a5f09d807e082fc2a494dd7e (patch) | |
tree | 300a8852fa05f7bb48571b0bd36c3c25d6263410 | |
parent | Renamed pages list_notification and list_favorites to notifications and favor... (diff) | |
download | newspipe-6b4eff20bea59339a5f09d807e082fc2a494dd7e.tar.gz newspipe-6b4eff20bea59339a5f09d807e082fc2a494dd7e.tar.bz2 newspipe-6b4eff20bea59339a5f09d807e082fc2a494dd7e.zip |
Improvement of mail notification for new articles (HTML output).
-rwxr-xr-x | feedgetter.py | 10 | ||||
-rwxr-xr-x | utils.py | 11 |
2 files changed, 13 insertions, 8 deletions
diff --git a/feedgetter.py b/feedgetter.py index 6dc69cf8..9143de33 100755 --- a/feedgetter.py +++ b/feedgetter.py @@ -131,6 +131,7 @@ class FeedGetter(object): description = "" try: + # try. Will only success if the article is not already in the data base self.c.execute('insert into articles values (?, ?, ?, ?, ?, ?, ?)', (\ datetime(*article.updated_parsed[:6]), \ utils.clear_string(article.title.encode('utf-8')), \ @@ -142,17 +143,18 @@ class FeedGetter(object): result = self.c.execute("SELECT mail from feeds WHERE feed_site_link='" + \ a_feed.feed.link.encode('utf-8') + "'").fetchall() if result[0][0] == "1": + # if subscribed to the current feed # send the article by e-mail try: - threading.Thread(None, utils.send_mail, \ - None, (utils.mail_from, utils.mail_to, \ - a_feed.feed.title.encode('utf-8'), description) \ + threading.Thread(None, utils.send_mail, None, (utils.mail_from, utils.mail_to, \ + a_feed.feed.title.encode('utf-8'), \ + utils.clear_string(article.title.encode('utf-8')), description) \ ).start() except Exception, e: # SMTP acces denied, to many SMTP connections, etc. print e except sqlite3.IntegrityError: - # article already in the base + # article already in the data base pass except: # Missing information (updated_parsed, ...) @@ -213,13 +213,16 @@ def tag_cloud(tags, query="word_count"): (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, calendar.month_name[int(word)])) \ for (word, count) in tags]) -def send_mail(mfrom, mto, feed_title, message): - """Send the warning via mail +def send_mail(mfrom, mto, feed_title, article_title, description): """ - mail = MIMEText(message) + Send the article via mail. + """ + content = """<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n%s\n</body>\n</html>""" % \ + (feed_title + ": " + article_title, description) + mail = MIMEText(content) mail['From'] = mfrom mail['To'] = mto - mail['Subject'] = '[pyAggr3g470r] News from ' + feed_title + mail['Subject'] = '[pyAggr3g470r] - ' + feed_title + ": " + article_title #email['Text'] = message server = smtplib.SMTP(smtp_server) |