diff --git a/eas/api/instagram/lamadava.py b/eas/api/instagram/lamadava.py index 68e90dc..d59d6b6 100644 --- a/eas/api/instagram/lamadava.py +++ b/eas/api/instagram/lamadava.py @@ -9,7 +9,6 @@ LAMADAVA_APIK = settings.LAMADAVA_APIK LOG = logging.getLogger(__name__) -MAX_PAGE_LAMADAVA = 50 ONE_MINUTE = 60 # seconds @@ -28,10 +27,9 @@ def _session(): # pragma: no cover def fetch_comments(media_pk): # pragma: no cover LOG.info("Sending request to lamadava for %s", media_pk) response = _session().get( - "https://api.lamadava.com/gql/comments", + "https://api.lamadava.com/v2/media/comments", params={ - "media_id": media_pk, - "amount": MAX_PAGE_LAMADAVA, + "id": media_pk, "access_key": LAMADAVA_APIK, }, timeout=ONE_MINUTE * 2, @@ -39,7 +37,7 @@ def fetch_comments(media_pk): # pragma: no cover if not response.ok: LOG.warning("Failed lamadava request! %s", response.text) with contextlib.suppress(Exception): - if response.json()["exc_type"] == "NotFoundError": + if response.json()["exc_type"] in ("NotFoundError", "MediaUnavailable"): return [] response.raise_for_status() - return response.json() + return response.json()["response"]["comments"]