Skip to content

fix(instagram): recursively collect explore media across nested layouts (#2091)#2118

Open
LeoLin990405 wants to merge 1 commit into
jackwener:mainfrom
LeoLin990405:fix/instagram-explore-nested-media
Open

fix(instagram): recursively collect explore media across nested layouts (#2091)#2118
LeoLin990405 wants to merge 1 commit into
jackwener:mainfrom
LeoLin990405:fix/instagram-explore-nested-media

Conversation

@LeoLin990405

Copy link
Copy Markdown
Contributor

What

opencli instagram explore returns [] 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

  • Convert the declarative pipeline adapter to a func adapter (matching clis/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-page fetch and returns { ok, data } | { error }; the func unwraps the Browser Bridge {session,data} envelope and throws CommandExecutionError on failure.
  • collectExploreMedia(data, limit) recursively walks sectional_items, collecting every distinct node.media (deduped by pk || id || code), mapping to rank/user/caption/likes/comments/type. likes falls back to play_count for 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_count fallback, empty/null input, media without a stable id ignored, plus func tests (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

…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[autofix] instagram/explore: empty result (explore_grid response shape drift)

1 participant