aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-03-27 23:12:00 +0200
committerGravatar Tom Willemsen2012-03-27 23:12:00 +0200
commitd959e7dc954553913f66fe133a80e3e9f7d63bd8 (patch)
tree916a03218fbe3df42c25e3c6b8653e941709cf1c
parent3bf5e5208ece3d71debc98552bf0dd71c65a9626 (diff)
downloadryuslash.org-d959e7dc954553913f66fe133a80e3e9f7d63bd8.tar.gz
ryuslash.org-d959e7dc954553913f66fe133a80e3e9f7d63bd8.zip
If no parsed date could be found, now() should be used
-rw-r--r--aggregator/management/commands/loadfeeds.py16
1 files 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: