forked from tanner/qotnews
Fix lobsters comment parsing
This commit is contained in:
parent
f049d194ab
commit
074b898508
|
@ -69,19 +69,17 @@ def iter_comments(flat_comments):
|
||||||
c = make_comment(comment)
|
c = make_comment(comment)
|
||||||
indent = comment['depth']
|
indent = comment['depth']
|
||||||
|
|
||||||
if indent == 1:
|
if indent == 0:
|
||||||
nested_comments.append(c)
|
nested_comments.append(c)
|
||||||
parent_stack = [c]
|
parent_stack = [c]
|
||||||
else:
|
else:
|
||||||
parent_stack = parent_stack[:indent-1]
|
parent_stack = parent_stack[:indent]
|
||||||
p = parent_stack[-1]
|
p = parent_stack[-1]
|
||||||
p['comments'].append(c)
|
p['comments'].append(c)
|
||||||
parent_stack.append(c)
|
parent_stack.append(c)
|
||||||
return nested_comments
|
return nested_comments
|
||||||
|
|
||||||
def story(ref):
|
def story(ref):
|
||||||
return False # TODO: remove
|
|
||||||
|
|
||||||
r = api(API_ITEM, ref)
|
r = api(API_ITEM, ref)
|
||||||
if not r:
|
if not r:
|
||||||
logging.info('Bad Lobsters API response.')
|
logging.info('Bad Lobsters API response.')
|
||||||
|
@ -114,5 +112,5 @@ def story(ref):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#print(feed())
|
#print(feed())
|
||||||
import json
|
import json
|
||||||
print(json.dumps(story('fzvd1v')))
|
print(json.dumps(story('fzvd1v'), indent=4))
|
||||||
#print(story(20802050))
|
#print(json.dumps(story('ixyv5u'), indent=4))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user