From d959e7dc954553913f66fe133a80e3e9f7d63bd8 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 27 Mar 2012 23:12:00 +0200 Subject: If no parsed date could be found, now() should be used --- aggregator/management/commands/loadfeeds.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/aggregator/management/commands/loadfeeds.py b/aggregator/management/commands/loadfeeds.py index bedf65d..2bee069 100644 --- a/aggregator/management/commands/loadfeeds.py +++ b/aggregator/management/commands/loadfeeds.py @@ -21,11 +21,15 @@ class Command(BaseCommand): for entry in parsed.entries: if not Post.objects.filter(post_id=entry.id).exists(): dt = entry.updated_parsed \ - or entry.published_parsed \ - or datetime.datetime.now() - updated = datetime.datetime( - dt.tm_year, dt.tm_mon, dt.tm_mday, - dt.tm_hour, dt.tm_min, dt.tm_sec) + or entry.published_parsed + + if dt: + updated = datetime.datetime( + dt.tm_year, dt.tm_mon, dt.tm_mday, + dt.tm_hour, dt.tm_min, dt.tm_sec) + else: + updated = datetime.datetime.now() + post = Post(post_id=entry.id, title=entry.title, remote_url=entry.link, @@ -36,7 +40,7 @@ class Command(BaseCommand): content = entry.content[0]['value'] else: content = entry.summary - + if feed.with_markdown: post.body = markdown.markdown(content) else: -- cgit v1.2.3-54-g00ecf