Skip inactive bloggers

Don't try to parse the feeds of bloggers with "end:" date in the past.
This commit is contained in:
Thomas Renger 2020-02-29 16:13:13 +01:00
parent da35708096
commit 33a6e74aa8
1 changed files with 11 additions and 4 deletions

View File

@ -28,6 +28,7 @@ def parse_published(pub):
return parse(pub).astimezone(tz.tzlocal()).replace(tzinfo=None)
except:
return parse(pub).replace(tzinfo=None)
def get_date(post):
for k in ('published', 'created', 'updated'):
if k in post:
@ -71,10 +72,16 @@ if len(sys.argv) > 1:
parse_feeds(weeks, l[3])
else:
for (username, u) in list(users.items()):
blogs = log.setdefault(username, {})
for l in u['links']:
weeks = blogs.setdefault(l[0], [])
parse_feeds(weeks, l[3])
print("User: ",u)
if 'end' in u:
enddate = datetime.datetime.strptime(u['end'],'%Y/%m/%d')
if enddate < datetime.datetime.now():
print("User inactive")
continue
blogs = log.setdefault(username, {})
for l in u['links']:
weeks = blogs.setdefault(l[0], [])
parse_feeds(weeks, l[3])
with open('out/report.yml', 'w') as f:
yaml.safe_dump(log, f)