From 27a1089e1f5d2c7f6a3cea4b1aa4750ed1f129a3 Mon Sep 17 00:00:00 2001 From: ponei Date: Thu, 7 May 2026 23:51:22 -0300 Subject: [PATCH] api/instagram: prefer graphql over embed for posts --- api/src/processing/services/instagram.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/processing/services/instagram.js b/api/src/processing/services/instagram.js index 0fa25527..e20a3076 100644 --- a/api/src/processing/services/instagram.js +++ b/api/src/processing/services/instagram.js @@ -305,6 +305,8 @@ export default function instagram(obj) { if (sidecar) { const picker = sidecar.edges.filter(e => e.node?.display_url) .map((e, i) => { + // if extracted from HTML embed, the first GraphVideo node from a "multipost" post sometimes + // reports `is_video` without a `video_url`. this also breaks the official Instagram "multipost" embed. const type = e.node?.is_video && e.node?.video_url ? "video" : "photo"; let url; @@ -436,13 +438,13 @@ export default function instagram(obj) { if (media_id && !hasData(data)) data = await requestMobileApi(media_id); if (media_id && cookie && !hasData(data)) data = await requestMobileApi(media_id, { cookie }); - // html embed (no cookie, cookie) - if (!hasData(data)) data = await requestHTML(id); - if (!hasData(data) && cookie) data = await requestHTML(id, cookie); - // web app graphql api (no cookie, cookie) if (!hasData(data)) data = await requestGQL(id); if (!hasData(data) && cookie) data = await requestGQL(id, cookie); + + // html embed (no cookie, cookie) + if (!hasData(data)) data = await requestHTML(id); + if (!hasData(data) && cookie) data = await requestHTML(id, cookie); } catch {} if (!hasData(data)) {