mirror of
https://github.com/instaloader/instaloader.git
synced 2026-10-16 13:48:03 -07:00
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>
This commit is contained in:
@@ -395,7 +395,10 @@ class InstaloaderContext:
|
|||||||
:param session: Session to use, or None to use self.session
|
:param session: Session to use, or None to use self.session
|
||||||
:param use_post: Use POST instead of GET to make the request
|
:param use_post: Use POST instead of GET to make the request
|
||||||
:return: Decoded response dictionary
|
: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 QueryReturnedNotFoundException: When the server responds with a 404.
|
||||||
:raises ConnectionException: When query repeatedly failed.
|
:raises ConnectionException: When query repeatedly failed.
|
||||||
|
|
||||||
@@ -447,6 +450,15 @@ class InstaloaderContext:
|
|||||||
response_headers.clear()
|
response_headers.clear()
|
||||||
response_headers.update(resp.headers)
|
response_headers.update(resp.headers)
|
||||||
if resp.status_code == 400:
|
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))
|
raise QueryReturnedBadRequestException(self._response_error(resp))
|
||||||
if resp.status_code == 404:
|
if resp.status_code == 404:
|
||||||
raise QueryReturnedNotFoundException(self._response_error(resp))
|
raise QueryReturnedNotFoundException(self._response_error(resp))
|
||||||
|
|||||||
Reference in New Issue
Block a user