fix(instagram): recursively collect explore media across nested layouts (#2091)#2118
Open
LeoLin990405 wants to merge 1 commit into
Open
fix(instagram): recursively collect explore media across nested layouts (#2091)#2118LeoLin990405 wants to merge 1 commit into
LeoLin990405 wants to merge 1 commit into
Conversation
…ts (jackwener#2091) instagram explore returned [] despite HTTP 200: IG moved explore_grid media out of the flat sectional_items[].layout_content.medias[] path into mixed nested layout shapes (one_by_two_item.clips.items[].media, fill_items[], …), which the adapter no longer read. Convert the pipeline adapter to a func (like clis/instagram/download.js) so the transform runs in Node and is unit-testable. buildExploreFetchScript() does the in-page fetch and returns { ok, data } | { error }; collectExploreMedia() recursively walks sectional_items collecting every distinct node.media (deduped by pk/id/code) and maps to rank/user/caption/likes/comments/type. likes falls back to play_count for clips/reels, and the generic walk still matches the legacy flat path. Adds clis/instagram/explore.test.js (11 JSON-fixture tests).
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
opencli instagram explorereturns[]despite HTTP 200 from/api/v1/discover/web/explore_grid/. Closes #2091.Root cause
IG moved explore media out of the flat
sectional_items[].layout_content.medias[]path into mixed nested layout shapes (one_by_two_item.clips.items[].media,fill_items[], …). The adapter only read the flat path.Fix
pipelineadapter to afuncadapter (matchingclis/instagram/download.js) so the transform runs in Node and is unit-testable. Same site/name/access/domain/args/columns — the command contract and manifest are unchanged.buildExploreFetchScript()does only the in-pagefetchand returns{ ok, data }|{ error }; the func unwraps the Browser Bridge{session,data}envelope and throwsCommandExecutionErroron failure.collectExploreMedia(data, limit)recursively walkssectional_items, collecting every distinctnode.media(deduped bypk || id || code), mapping torank/user/caption/likes/comments/type.likesfalls back toplay_countfor clips/reels. The generic walk also still matches the legacy flat path (backward compatible).Test
clis/instagram/explore.test.js— 11 JSON-fixture tests (no live IG): new nested shapes, legacy flat path, dedupe (incl. two distinct objects sharing a pk) + limit,play_countfallback, empty/null input, media without a stable id ignored, plusfunctests (ranked rows, envelope unwrap, fetch-failure → CommandExecutionError).Verification
vitest run clis/instagram/explore.test.js→ 11 passed; all Instagram adapter tests pass (7 files, 92+ tests)check:typed-error-lint/check:silent-column-drop→ no new violations