From 166e12b0d2c3350b28ed159b43a738cb09ebf1f6 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 27 Sep 2016 09:35:38 +0200 Subject: Fixed a bug with SQLite support. --- src/web/lib/article_utils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/web/lib') diff --git a/src/web/lib/article_utils.py b/src/web/lib/article_utils.py index 46bb9461..b5b9f246 100644 --- a/src/web/lib/article_utils.py +++ b/src/web/lib/article_utils.py @@ -36,21 +36,23 @@ def construct_article(entry, feed): feed = feed.dump() "Safe method to transorm a feedparser entry into an article" now = datetime.now() - date, updated_date = None, None - for date_key in ('published', 'updated'): + date = None + for date_key in ('published', 'created', 'date'): if entry.get(date_key): try: - date = dateutil.parser.parse(entry[date_key]) + date = dateutil.parser.parse(entry[date_key])\ + .astimezone(timezone.utc) except Exception: pass else: break + + updated_date = None try: updated_date = dateutil.parser.parse(entry['updated']) except Exception: pass content = get_article_content(entry) - article_link = entry.get('link') return {'feed_id': feed['id'], @@ -60,9 +62,9 @@ def construct_article(entry, feed): 'title': entry.get('title', 'No title'), 'readed': False, 'like': False, 'content': content, - 'retrieved_date': now.isoformat(), - 'date': (date or now).isoformat(), - 'updated_date': (updated_date or date or now).isoformat()} + 'retrieved_date': now, + 'date': date or now, + 'updated_date': updated_date or date or now} def get_article_content(entry): content = '' -- cgit