]> projects.mako.cc - iron-blogger/blobdiff - scan-feeds.py
updated so that it copies the blogs over
[iron-blogger] / scan-feeds.py
index 7e27b8c2a5c8e0e9012b744a19f2950747e7e9ff..b3fe213f2c0095f831e84522c244e17ce0de7f0f 100755 (executable)
@@ -15,15 +15,15 @@ try:
 except IOError:
     log = {}
 
 except IOError:
     log = {}
 
-START = datetime.datetime(2009, 12, 21, 6)
+START = datetime.datetime(2011, 10, 24, 6)
 
 def parse_published(pub):
     return parse(pub).astimezone(tz.tzlocal()).replace(tzinfo=None)
 
 def get_date(post):
 
 def parse_published(pub):
     return parse(pub).astimezone(tz.tzlocal()).replace(tzinfo=None)
 
 def get_date(post):
-    if 'published' in post:
-        return post.published
-    return post.updated
+    for k in ('published', 'created', 'updated'):
+        if k in post:
+            return post[k]
 
 def get_link(post):
     return post.link
 
 def get_link(post):
     return post.link
@@ -48,10 +48,16 @@ def parse_feeds(weeks, uri):
         if post['url'] not in [p['url'] for p in weeks[wn]]:
             weeks[wn].append(post)
 
         if post['url'] not in [p['url'] for p in weeks[wn]]:
             weeks[wn].append(post)
 
-for (username, u) in users.items():
-    weeks = log.setdefault(username, [])
-    for l in u['links']:
-        parse_feeds(weeks, l[2])
+if len(sys.argv) > 1:
+    for username in sys.argv[1:]:
+        weeks = log.setdefault(username, [])
+        for l in users[username]['links']:
+            parse_feeds(weeks, l[2])
+else:
+    for (username, u) in users.items():
+        weeks = log.setdefault(username, [])
+        for l in u['links']:
+            parse_feeds(weeks, l[2])
 
 with open('out/report.yml', 'w') as f:
     yaml.safe_dump(log, f)
 
 with open('out/report.yml', 'w') as f:
     yaml.safe_dump(log, f)

Benjamin Mako Hill || Want to submit a patch?