Filter out False comments

This commit is contained in:
2019-08-30 06:23:14 +00:00
parent 20a9d9d452
commit 2ede5ed6ff
3 changed files with 36 additions and 23 deletions

View File

@@ -25,12 +25,16 @@ def feed():
return api(API_TOPSTORIES) or []
def comment(i):
if 'author' not in i:
return False
c = {}
c['author'] = i.get('author', '')
c['score'] = i.get('points', 0)
c['date'] = i.get('created_at_i', 0)
c['text'] = i.get('text', '')
c['comments'] = [comment(j) for j in i['children']]
c['comments'] = list(filter(bool, c['comments']))
return c
def comment_count(i):
@@ -55,6 +59,7 @@ def story(ref):
s['link'] = SITE_LINK(ref)
s['url'] = r.get('url', '')
s['comments'] = [comment(i) for i in r['children']]
s['comments'] = list(filter(bool, s['comments']))
s['num_comments'] = comment_count(s) - 1
if 'text' in r and r['text']: