[instagram] fix highlights extraction #2197
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the highlight extractor fails when there are more than 30 reel_ids supplied to the "/v1/feed/reels_media/" endpoint.
For example, fetching highlights from "https://www.instagram.com/f1/" (87 highlights at the time I'm writing this)
will respond with status code 400.
Initially I tried splitting reel_ids into chunks of length 30, however, I quickly found that I consistently get 5xx responses when the total number of reel_ids is above 30 (I waited an entire week just to make sure that I wasn't being rate limited). When the total number of reel_ids is <= 30 (example account "https://www.instagram.com/bemytravelmuse/", 27 highlights at the time I'm writing this), you can fetch everything with a single request, however, in my case 5xx responses can still be frequently observed.
I haven't tested everything thoroughly, but it looks like chunks of 15 seem to work most of the time. That being said, it might be a good idea to start at 30 and just reduce the chunk size (e.g. halve it) until you stop getting 5xx responses.