From a2715cbe03f7a3ef759e49d5a626c2c764379019 Mon Sep 17 00:00:00 2001 From: Eduardo Kalinowski Date: Thu, 29 Apr 2021 16:14:23 -0300 Subject: [PATCH] Show progress of profile scraping (#1114) --- instaloader/instaloader.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index d2475af..bf658c3 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -736,10 +736,16 @@ class Instaloader: self.context.log("Retrieving all visible stories...") else: userids = [p if isinstance(p, int) else p.userid for p in userids] + profile_count = len(userids) - for user_story in self.get_stories(userids): + for i, user_story in enumerate(self.get_stories(userids), start=1): name = user_story.owner_username - self.context.log("Retrieving stories from profile {}.".format(name)) + if profile_count is not None: + msg = "[{0:{w}d}/{1:{w}d}] Retrieving stories from profile {2}.".format(i, profile_count, name, + w=len(str(profile_count))) + else: + msg = "[{:3d}] Retrieving stories from profile {}.".format(i, name) + self.context.log(msg) totalcount = user_story.itemcount count = 1 for item in user_story.get_items(): @@ -1246,7 +1252,9 @@ class Instaloader: # error_handler type is Callable[[Optional[str]], ContextManager[None]] (not supported with Python 3.5.0..3.5.3) error_handler = _error_raiser if raise_errors else self.context.error_catcher - for profile in profiles: + for i, profile in enumerate(profiles, start=1): + self.context.log("[{0:{w}d}/{1:{w}d}] Downloading profile {2}".format(i, len(profiles), profile.username, + w=len(str(len(profiles))))) with error_handler(profile.username): # type: ignore # (ignore type for Python 3.5 support) profile_name = profile.username