api/instagram: prefer graphql over embed for posts#1554
Open
ponei wants to merge 1 commit into
Open
Conversation
zImPatrick
pushed a commit
to zImPatrick/cobalt
that referenced
this pull request
Jun 21, 2026
(cherry picked from commit 27a1089) imputnet#1554
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
what happened
When scraping the embed HTML for an Instagram post, carousel ("multipost") posts can expose media through a
contextJSONpayload. This property is empty for single-video posts, but appears for posts with multiple media items.The problem is that, if a "multipost" has multiple videos, Instagram marks the first video node with
is_video, but does not include a usablevideo_url.The extractor then checks for both
is_videoandvideo_urlbefore treating a node as downloadable video media:cobalt/api/src/processing/services/instagram.js
Line 308 in a636575
Because the affected node is missing
video_url, the extractor cannot expose it as avideoand falls back to treating it as aphoto.This also appears to affect Instagram's official embed for the same "multipost" post. Example from the original issue:
embed2.mp4
what changed
This pull request changes the Instagram post fallback order so that the GraphQL API is tried before the embed HTML scrape.
GraphQL still returns data for single-video posts, and it also returns the correct
video_urlfor the affected "multipost" posts. Keeping embed HTML as a later fallback preserves the existing recovery path without letting incomplete embed data win too early.This fixes #1550