diff --git a/bot/modules/instagram/extractor.py b/bot/modules/instagram/extractor.py index f85eebe..af16453 100644 --- a/bot/modules/instagram/extractor.py +++ b/bot/modules/instagram/extractor.py @@ -4,7 +4,7 @@ from typing import Optional import orjson from curl_cffi.requests import AsyncSession -from .auth import APP_ID, UA, NoSessions, Session, SessionPool +from .auth import APP_ID, UA, LoginChallenge, NoSessions, Session, SessionPool from .content import Audio, Item, Post POST_RE = re.compile( @@ -130,6 +130,14 @@ class Instagram: except Exception: body = None + # A locked account is not a session problem: rotating to another + # session or logging in again cannot clear it, and trying only + # burns login attempts until Instagram answers 429 instead. + if isinstance(body, dict) and body.get("checkpoint_url"): + raise LoginChallenge( + body.get("message") or "Instagram wants a checkpoint cleared" + ) + # An expired session is not a 401: Instagram bounces the API call # to /accounts/login/, which bounces back, so following redirects # burned 30 hops and surfaced a curl error instead of a dead