From 074b8985087bd049cf59eb8c4bc6057bf2e5a273 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 27 Feb 2024 18:47:00 +0000 Subject: [PATCH] Fix lobsters comment parsing --- apiserver/feeds/lobsters.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apiserver/feeds/lobsters.py b/apiserver/feeds/lobsters.py index 58ec9eb..da50a74 100644 --- a/apiserver/feeds/lobsters.py +++ b/apiserver/feeds/lobsters.py @@ -69,19 +69,17 @@ def iter_comments(flat_comments): c = make_comment(comment) indent = comment['depth'] - if indent == 1: + if indent == 0: nested_comments.append(c) parent_stack = [c] else: - parent_stack = parent_stack[:indent-1] + parent_stack = parent_stack[:indent] p = parent_stack[-1] p['comments'].append(c) parent_stack.append(c) return nested_comments def story(ref): - return False # TODO: remove - r = api(API_ITEM, ref) if not r: logging.info('Bad Lobsters API response.') @@ -114,5 +112,5 @@ def story(ref): if __name__ == '__main__': #print(feed()) import json - print(json.dumps(story('fzvd1v'))) - #print(story(20802050)) + print(json.dumps(story('fzvd1v'), indent=4)) + #print(json.dumps(story('ixyv5u'), indent=4))