From b7ef306374626316d209236342d13bcd666d5d17 Mon Sep 17 00:00:00 2001 From: Denys Date: Sat, 8 Nov 2025 18:10:47 +0100 Subject: [PATCH] Abort download on {feedback,checkpoint,challenge}_required (#2612) Handle Instagram feedback_required/checkpoint_required/challenge_required responses with a AbortDownloadException, causing the resumable iteration to be interrupted. Co-authored-by: Alexander Graf <17130992+aandergr@users.noreply.github.com> --- instaloader/instaloadercontext.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index d447002..f2f61d5 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -395,7 +395,10 @@ class InstaloaderContext: :param session: Session to use, or None to use self.session :param use_post: Use POST instead of GET to make the request :return: Decoded response dictionary - :raises QueryReturnedBadRequestException: When the server responds with a 400. + :raises AbortDownloadException: When the server responds with + 'feedback_required'/'checkpoint_required'/'challenge_required' + :raises QueryReturnedBadRequestException: When the server responds with a 400 (and not + 'feedback_required'/'checkpoint_required'/'challenge_required'). :raises QueryReturnedNotFoundException: When the server responds with a 404. :raises ConnectionException: When query repeatedly failed. @@ -447,6 +450,15 @@ class InstaloaderContext: response_headers.clear() response_headers.update(resp.headers) if resp.status_code == 400: + with suppress(json.decoder.JSONDecodeError): + if resp.json().get("message") in [ + "feedback_required", + "checkpoint_required", + "challenge_required", + ]: + # Raise AbortDownloadException in case of substantial Instagram + # requirements to stop producing more requests + raise AbortDownloadException(self._response_error(resp)) raise QueryReturnedBadRequestException(self._response_error(resp)) if resp.status_code == 404: raise QueryReturnedNotFoundException(self._response_error(resp))