There can be comments without any answers

This commit is contained in:
Dāvis 2019-04-14 00:40:46 +03:00
parent adb9f3a346
commit 87d877e650

View File

@ -276,7 +276,7 @@ class Instaloader:
comments.extend(_postcomment_asdict(comment) for comment in post.get_comments())
if comments:
comments = get_unique_comments(comments, combine_answers=True)
answer_ids = set(int(answer['id']) for comment in comments for answer in comment.get('answers'))
answer_ids = set(int(answer['id']) for comment in comments for answer in comment.get('answers', []))
with open(filename, 'w') as file:
file.write(json.dumps(list(filter(lambda t: int(t['id']) not in answer_ids, comments)), indent=4))
self.context.log('comments', end=' ', flush=True)