diff --git a/docs/cli-options.rst b/docs/cli-options.rst index 05a0206..2f8b7d3 100644 --- a/docs/cli-options.rst +++ b/docs/cli-options.rst @@ -67,7 +67,7 @@ What to Download of each Post Download and update comments for each post. This requires an additional request to the Instagram server for each post, which is why it is disabled by - default. + default. Requires :option:`--login`. .. option:: --no-captions diff --git a/instaloader/__main__.py b/instaloader/__main__.py index c7c46b1..5a8e5ba 100644 --- a/instaloader/__main__.py +++ b/instaloader/__main__.py @@ -367,7 +367,7 @@ def main(): g_post.add_argument('-C', '--comments', action='store_true', help='Download and update comments for each post. ' 'This requires an additional request to the Instagram ' - 'server for each post, which is why it is disabled by default.') + 'server for each post, which is why it is disabled by default. Requires --login.') g_post.add_argument('--no-captions', action='store_true', help='Do not create txt files.') g_post.add_argument('--post-metadata-txt', action='append', diff --git a/instaloader/structures.py b/instaloader/structures.py index b99ca87..c0dc373 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -685,6 +685,9 @@ class Post: .. versionchanged:: 4.7 Change return type to ``Iterable``. """ + if not self._context.is_logged_in: + raise LoginRequiredException("--login required to access comments of a post.") + def _postcommentanswer(node): return PostCommentAnswer(id=int(node['id']), created_at_utc=datetime.utcfromtimestamp(node['created_at']),