From 87d877e650cd8020b04b8b51be120599a441fd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis?= Date: Sun, 14 Apr 2019 00:40:46 +0300 Subject: [PATCH] There can be comments without any answers --- instaloader/instaloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 8e90fde..6a52f8e 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -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)