aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-27 09:35:38 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-27 09:35:38 +0200
commit166e12b0d2c3350b28ed159b43a738cb09ebf1f6 (patch)
treed3b83827b9c01b0f93b354016e83d2939985aa28 /src
parentUpdated dependencies. (diff)
downloadnewspipe-166e12b0d2c3350b28ed159b43a738cb09ebf1f6.tar.gz
newspipe-166e12b0d2c3350b28ed159b43a738cb09ebf1f6.tar.bz2
newspipe-166e12b0d2c3350b28ed159b43a738cb09ebf1f6.zip
Fixed a bug with SQLite support.
Diffstat (limited to 'src')
-rw-r--r--src/crawler/classic_crawler.py2
-rw-r--r--src/web/lib/article_utils.py16
2 files changed, 11 insertions, 7 deletions
diff --git a/src/crawler/classic_crawler.py b/src/crawler/classic_crawler.py
index cd395d0f..8b952940 100644
--- a/src/crawler/classic_crawler.py
+++ b/src/crawler/classic_crawler.py
@@ -148,6 +148,8 @@ async def insert_database(user, feed):
existing_article.dump())
continue
article = construct_article(article, feed)
+ print("test.............................................")
+ print(article)
try:
new_articles.append(art_contr.create(**article))
logger.info("New article % (%r) added.",
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 = ''
bgstack15