From a7d1c5bbb022eb207db93d55ee95953f68d827d7 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 10 Apr 2017 21:05:58 +0200 Subject: [PATCH] Make check_id() exceptions Non-fatal The check_id() step, including the get_username_by_id(), which is used to determine whether a profile's account name has changed since the last download using it's unique id when Instaloader is operating logged-in, is actually optional and should not cause termination in any case. --- instaloader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instaloader.py b/instaloader.py index a417174..c602d9c 100755 --- a/instaloader.py +++ b/instaloader.py @@ -40,6 +40,9 @@ class NonfatalException(InstaloaderException): class ProfileNotExistsException(NonfatalException): pass +class ProfileAccessDeniedException(NonfatalException): + pass + class ProfileHasNoPicsException(NonfatalException): pass @@ -91,8 +94,8 @@ def get_username_by_id(session: requests.Session, profile_id: int) -> str: "you (id: " + str(profile_id) + ").") else: if test_login(session): - raise ConnectionException("Username could not be determined due to connection error" + - " (id: "+ str(profile_id) +").") + raise ProfileAccessDeniedException("Username could not be determined due to error {0} (id: {1})." + .format(str(resp.status_code), str(profile_id))) raise LoginRequiredException("Login required to determine username (id: " + str(profile_id) + ").")