From 2dca99b89e35d10e19c5763241fae3ebe17620bb Mon Sep 17 00:00:00 2001 From: Eduardo Kalinowski Date: Thu, 30 Mar 2023 13:51:27 -0300 Subject: [PATCH] Abort the download when redirected to login (#1900) Abort the download when redirected to login (fixes #1882) --- instaloader/instaloadercontext.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index b19f1ba..75eeadd 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -335,8 +335,8 @@ class InstaloaderContext: redirect_url.startswith('https://i.instagram.com/accounts/login')): if not self.is_logged_in: raise LoginRequiredException("Redirected to login page. Use --login.") - # alternate rate limit exceeded behavior - raise TooManyRequestsException("Redirected to login") + raise AbortDownloadException("Redirected to login page. You've been logged out, please wait " + + "some time, recreate the session and try again") if redirect_url.startswith('https://{}/'.format(host)): resp = sess.get(redirect_url if redirect_url.endswith('/') else redirect_url + '/', params=params, allow_redirects=False)