diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 781bf013..20a4c1a3 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -748,13 +748,19 @@ class InstagramHighlightsExtractor(InstagramExtractor): endpoint = "/v1/highlights/{}/highlights_tray/".format(user["id"]) tray = self._request_api(endpoint)["tray"] - reel_ids = [highlight["id"] for highlight in tray] - endpoint = "/v1/feed/reels_media/" - params = {"reel_ids": reel_ids} - reels = self._request_api(endpoint, params=params)["reels"] - return [reels[rid] for rid in reel_ids] + # Anything above 30 responds with statuscode 400. + # 30 can work, however, sometimes the API will respond with 560 or 500. + chunk_size = 5 + endpoint = "/v1/feed/reels_media/" + + for offset in range(0, len(reel_ids), chunk_size): + chunk_ids = reel_ids[offset : offset+chunk_size] + params = {"reel_ids": chunk_ids} + reels = self._request_api(endpoint, params=params)["reels"] + for reel_id in chunk_ids: + yield reels[reel_id] class InstagramReelsExtractor(InstagramExtractor):