From 3ec908b412969bd0d98915667a17c90a1de1e7d1 Mon Sep 17 00:00:00 2001 From: Giulio Malitesta Date: Thu, 23 Jul 2026 17:21:48 +0200 Subject: [PATCH] fix: handle sidecar children without __typename in embed fallback The embed-page extraction path (GetEmbedMedia) returns edge_sidecar_to_children nodes without a __typename field (unlike the GQL API), using an is_video boolean instead. The sidecar-parsing switch only matched on Typename, so any carousel post resolved via the embed fallback got items with zero formats, failing downstream with "no formats found for media item at index N" even though the post is public and available. --- internal/extractors/instagram/util.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/extractors/instagram/util.go b/internal/extractors/instagram/util.go index 7c7276d..5ce0f3a 100644 --- a/internal/extractors/instagram/util.go +++ b/internal/extractors/instagram/util.go @@ -97,8 +97,18 @@ func ParseGQLMedia(ctx *models.ExtractorContext, data *Media) (*models.Media, er item := media.NewItem() node := edges[i].Node + // The embed page's sidecar children omit __typename entirely + // (unlike the GQL API), so fall back to the is_video flag, + // which is always present, when Typename didn't match. + isVideo := node.IsVideo switch node.Typename { case "GraphVideo", "XDTGraphVideo": + isVideo = true + case "GraphImage", "XDTGraphImage": + isVideo = false + } + + if isVideo { item.AddFormats(&models.MediaFormat{ FormatID: "video", Type: database.MediaTypeVideo, @@ -109,8 +119,7 @@ func ParseGQLMedia(ctx *models.ExtractorContext, data *Media) (*models.Media, er Width: node.Dimensions.Width, Height: node.Dimensions.Height, }) - - case "GraphImage", "XDTGraphImage": + } else { item.AddFormats(&models.MediaFormat{ FormatID: "image", Type: database.MediaTypePhoto,