zs

Zeitungsschau rss to email converter
git clone git://r-36.net/zs
Log | Files | Refs | LICENSE

commit f98e35d1336421d251ad29089a23f77125aabc53
parent 931341e7b92f25527dc5894fafb8a6ff4c645ff5
Author: Christoph Lohmann <20h@r-36.net>
Date:   Thu, 27 Mar 2014 17:24:40 +0100

Changes:

* Add a way to handle the Enclosure from a group file entry too.
* Support the decoding of HTML entities in headers.
* Handle some more error.

Diffstat:
feed.py | 7+++++++
feedemail.py | 4++++
zs.py | 2++
3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/feed.py b/feed.py @@ -130,6 +130,13 @@ def parse(astr): else: article["file"] = str(entry.enclosure) + if hasattr(entry, "group") and \ + hasattr(entry.group, "content"): + if "url" in entry.group.content: + article["file"] = \ + str(entry.group.content.\ + attrib["file"]) + # updated if hasattr(entry, "updated"): article["updated"] = parseiso(entry.updated) diff --git a/feedemail.py b/feedemail.py @@ -11,6 +11,7 @@ from email.mime.multipart import MIMEMultipart from email.utils import formataddr, formatdate, parseaddr from email.header import Header import time +import lxml.html.soupparser import html2text as h2t h2t.UNICODE_SNOB = 1 @@ -20,6 +21,9 @@ h2t.INLINE_LINKS = 0 html2text = h2t.html2text def normalizeheader(hstr): + hstr = lxml.html.soupparser.tostring(hstr.replace("\n", " ").strip(),\ + encoding="utf-8") + return hstr.replace("\n", " ").strip() def send(feed, to, smtphost="localhost", smtpport=None, ssl="False", \ diff --git a/zs.py b/zs.py @@ -37,6 +37,8 @@ def run(db, selfeed=None, dryrun=False): retries += 1 except socket.gaierror: continue + except urllib.error.URLError: + continue except TimeoutError: continue except ConnectionResetError: