aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-03-05 07:28:30 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-03-05 07:28:30 +0100
commit5aebb0bd464cf7af712de1cb0f79754fd9afc4a6 (patch)
tree3c4f6980667190dd1e7075e64b7801fb6bc7cda4 /pyaggr3g470r
parentTake advantage of some new fields of the Feed objects. (diff)
downloadnewspipe-5aebb0bd464cf7af712de1cb0f79754fd9afc4a6.tar.gz
newspipe-5aebb0bd464cf7af712de1cb0f79754fd9afc4a6.tar.bz2
newspipe-5aebb0bd464cf7af712de1cb0f79754fd9afc4a6.zip
Minor update to the 'feed' template.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/crawler.py13
-rw-r--r--pyaggr3g470r/templates/feed.html6
2 files changed, 11 insertions, 8 deletions
diff --git a/pyaggr3g470r/crawler.py b/pyaggr3g470r/crawler.py
index 22ed5acc..66195124 100644
--- a/pyaggr3g470r/crawler.py
+++ b/pyaggr3g470r/crawler.py
@@ -56,7 +56,6 @@ def get(*args, **kwargs):
return (yield from response.read_and_close(decode=False))
except Exception as e:
#print(e)
- feed.last_error = str(e)
return None
@asyncio.coroutine
@@ -72,16 +71,19 @@ def parse_feed(user, feed):
if data is None:
feed.error_count += 1
return
- feed.error_count = 0
-
- feed.last_retrieved = datetime.now()
a_feed = feedparser.parse(data)
if a_feed['bozo'] == 1:
- logger.error(a_feed['bozo_exception'])
+ #logger.error(a_feed['bozo_exception'])
+ feed.last_error = str(a_feed['bozo_exception'])
+ feed.error_count += 1
+ db.session.commit()
if a_feed['entries'] == []:
return
+ feed.last_retrieved = datetime.now(dateutil.tz.tzlocal())
+ feed.error_count = 0
+
# Feed informations
if feed.title == "":
try:
@@ -98,6 +100,7 @@ def parse_feed(user, feed):
feed.description = a_feed.feed.subtitle
except:
feed.description = ""
+ db.session.commit()
articles = []
for article in a_feed['entries']:
diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html
index 12a7aa50..acc1d3a2 100644
--- a/pyaggr3g470r/templates/feed.html
+++ b/pyaggr3g470r/templates/feed.html
@@ -15,7 +15,7 @@
{% endif %}
{% if feed.last_retrieved %}
- {{ _("Last download:") }} <pre>{{ feed.last_retrieved }}</pre><br />
+ {{ _("Last download:") }} {{ feed.last_retrieved | datetime }}<br />
{% endif %}
{% if feed.error_count > 2 %}
@@ -30,9 +30,9 @@
{{ _('Address of the feed') }}: <a href="{{ feed.link }}">{{ feed.link }}</a><br />
{% if feed.site_link != "" %}
- {{ _('Address of the site') }}: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a>
+ {{ _('Address of the site') }}: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a><br />
{% endif %}
- <br />
+
{% if feed.articles.all()|count != 0 %}
{{ _('The last article was posted') }} {{ elapsed.days }} {{ _('day(s) ago.') }}<br />
{{ _('Daily average') }}: {{ average }}, {{ _('between the') }} {{ first_post_date | datetime }} {{ _('and the') }} {{ end_post_date | datetime }}.
bgstack15