From 211b2269ffbd46a90d2d80602dad77fb62939c57 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 8 May 2018 18:10:28 +0200 Subject: [PATCH] download_profile: Request story only if has_highlight_reel This is a simple modification to save GraphQL queries, hence to more likely stay within rate limits without having to wait between profiles. Fixes #112. --- instaloader/instaloader.py | 9 ++++++--- instaloader/structures.py | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 3909bfa..999663b 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -699,9 +699,12 @@ class Instaloader: # Download stories, if requested if download_stories or download_stories_only: - with self.context.error_catcher("Download stories of {}".format(profile_name)): - self.download_stories(userids=[profile.userid], filename_target=profile_name, fast_update=fast_update, - storyitem_filter=storyitem_filter) + if profile.has_highlight_reel: + with self.context.error_catcher("Download stories of {}".format(profile_name)): + self.download_stories(userids=[profile.userid], filename_target=profile_name, + fast_update=fast_update, storyitem_filter=storyitem_filter) + else: + self.context.log("{} does not have any stories.".format(profile_name)) if download_stories_only: return diff --git a/instaloader/structures.py b/instaloader/structures.py index 460090d..764a10b 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -481,6 +481,10 @@ class Profile: def has_blocked_viewer(self) -> bool: return self._metadata('has_blocked_viewer') + @property + def has_highlight_reel(self) -> bool: + return self._metadata('has_highlight_reel') + @property def has_requested_viewer(self) -> bool: return self._metadata('has_requested_viewer')