From 283a2b15450f9e2859703971c50ff297322da975 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 2 Nov 2020 22:06:43 +0000 Subject: [PATCH] fix webworm comments --- apiserver/feed.py | 4 ++-- apiserver/feeds/webworm.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apiserver/feed.py b/apiserver/feed.py index 5976813..e22f224 100644 --- a/apiserver/feed.py +++ b/apiserver/feed.py @@ -17,10 +17,10 @@ TWO_DAYS = 60*60*24*2 def list(): feed = [] + feed += [(x, 'hackernews') for x in hackernews.feed()[:10]] + feed += [(x, 'tildes') for x in tildes.feed()[:10]] feed += [(x, 'reddit') for x in reddit.feed()[:15]] feed += [(x, 'webworm') for x in webworm.feed()[:15]] - feed += [(x, 'tildes') for x in tildes.feed()[:10]] - feed += [(x, 'hackernews') for x in hackernews.feed()[:10]] return feed def get_article(url): diff --git a/apiserver/feeds/webworm.py b/apiserver/feeds/webworm.py index 731063c..8de7be3 100644 --- a/apiserver/feeds/webworm.py +++ b/apiserver/feeds/webworm.py @@ -66,7 +66,7 @@ def comment(i): c = {} c['date'] = unix(i.get('date')) c['author'] = i.get('name', '') - c['score'] = o.get('reactions').get('❤') + c['score'] = i.get('reactions').get('❤') c['text'] = clean(i.get('body', '') or '') c['comments'] = [comment(j) for j in i['children']] c['comments'] = list(filter(bool, c['comments'])) @@ -100,7 +100,8 @@ def story(ref): s['title'] = r.get('title', '') s['link'] = r.get('canonical_url', '') s['url'] = r.get('canonical_url', '') - s['comments'] = [comment(i) for i in api(API_ITEM_COMMENTS, r.get('id'))] + comments = api(API_ITEM_COMMENTS, r.get('id')) + s['comments'] = [comment(i) for i in comments.get('comments')] s['comments'] = list(filter(bool, s['comments'])) s['num_comments'] = r.get('comment_count', 0)