From d2462686306de39f875ca67b7abe91ed3419bb03 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sun, 19 Mar 2017 12:52:07 +0100 Subject: [PATCH] Retry download anonymously if profile not exists In case you are blocked by a public profile which you intend to download, the server responds as if the profile would not exist. Now in this case, we retry the download without using an anonymous session. --- instaloader.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/instaloader.py b/instaloader.py index 23ef03b..e900119 100755 --- a/instaloader.py +++ b/instaloader.py @@ -670,8 +670,16 @@ def download_profiles(profilelist: List[str], username: Optional[str] = None, pa # Iterate through targets list and download them for target in targets: try: - download(target, session, profile_pic_only, download_videos, - geotags, fast_update, shorter_output, sleep, quiet) + try: + download(target, session, profile_pic_only, download_videos, + geotags, fast_update, shorter_output, sleep, quiet) + except ProfileNotExistsException as err: + if username is not None: + _log("\"Profile not exists\" - Trying again anonymously, helps in case you are just blocked") + download(target, get_anonymous_session(), profile_pic_only, download_videos, + geotags, fast_update, shorter_output, sleep, quiet) + else: + raise err except NonfatalException as err: failedtargets.append(target) print(err, file=sys.stderr)