Skip to content

Feat: Read the Instagram caption from the post URL - #23

Merged
Eschults merged 7 commits into
mainfrom
claude/amazing-cannon-zzdbek
Sep 26, 2026
Merged

Eschults merged 7 commits into
mainfrom
claude/amazing-cannon-zzdbek

Conversation

@Eschults

@Eschults Eschults commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Context

Changes

  • The issue form has a single required field: the post URL.
  • New scripts/add-recipe/instagram.js: when the request has no caption, headless Chromium (Playwright) opens the post and reads the caption and the author's handle from its og:description tag. No login needed.
  • The run fails when the page shows no caption, instead of letting the model guess one.
  • A caption passed in directly (workflow_dispatch) still skips the fetch, as a fallback. That input is now optional.
  • The workflow installs Chromium and its system libraries before the recipe step. playwright is a new dependency.
  • Gemini URL context was tried first and ruled out: Instagram refused Google's fetcher (URL_RETRIEVAL_STATUS_ERROR, run).
  • README updated.

Tests

  • test/instagram.test.js runs against a fake browser: happy path, no og:description, a description with no quoted caption, the browser closing on failure, quotes inside a caption, and a supplied caption or handle winning over the fetched one. test/issue.test.js covers a URL-only form.
  • A live workflow_dispatch run on 93923d7 with only a URL passed.
  • npm test: 18/19 pass. test/render.test.js needs an Eschults/cookbook checkout that the Claude session could not reach. It fails on main too.

@Eschults

Copy link
Copy Markdown
Owner Author

The live run failed before it could test anything: Write the recipe and open a pull request on 73ba290.

  • Gemini rejected the first call, the caption fetch, with 429 RESOURCE_EXHAUSTED ("check quota"). It never got as far as reading the post, so we still don't know whether URL context can read Instagram.
  • The request went out as expected: workflow_dispatch, empty caption, URL only. The workflow edit worked.
  • This is not something a code change fixes. Either GEMINI_API_KEY has used up its quota for now (today's runs for Ajouter Gratin de chou-fleur #18 and Ajouter Poulet crémeux au parmesan #20 used the same key), or the free tier doesn't allow the URL context tool on gemini-3.5-flash-lite. AI Studio's usage page for the key shows which.
  • I did not re-run it, since a retry right away would hit the same limit. Once the quota resets, or with billing turned on, run the workflow on this branch again with the same URL. I'm still watching this PR.

Session: https://claude.ai/code/session_01PqRBbb6QeVTurq7z7t8zkw


Generated by Claude Code

@Eschults

Copy link
Copy Markdown
Owner Author

The second run answered the open question: Gemini's URL context cannot read Instagram. Run log.

  • The quota had recovered: the call went through (126 tokens in, 43 out).
  • Gemini's fetcher got URL_RETRIEVAL_STATUS_ERROR for https://www.instagram.com/reel/DdrLS5ON1cI/. Instagram is turning Google's fetcher away.
  • The retrieval check worked: the run failed with Gemini could not read ... instead of using a caption the model made up. That is the failure the check exists to catch.
  • Nothing pushed, since there is no bug to fix here. The Gemini approach itself is ruled out.

Decision needed: have the runner fetch the post's public page (or its /embed/captioned/ variant) and read the caption from it? This session still cannot reach Instagram, so I would do it in two steps. First, a commit whose fetch logs the start of what the runner actually receives, run once on this branch. Then the parser, written against that real response. If Instagram shows a login wall to the runner too, the only option left is a paid caption API.

Session: https://claude.ai/code/session_01PqRBbb6QeVTurq7z7t8zkw


Generated by Claude Code

@Eschults
Eschults marked this pull request as ready for review September 26, 2026 11:46

@Eschults Eschults left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a self-review: Claude reviewed a PR it opened, and Edward wrote most of the current code. It is not an approval.

Found

  • Medium: the README said npm install downloads the browser Playwright drives. playwright has no install script, so a local fetch fails at chromium.launch().
  • Low: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD on the npm ci step does nothing, for the same reason, and its comment says otherwise.

Fixed

  • 884a8d5: the README now says to run npx playwright install chromium once, and the local-run commands include it.
  • Earlier, 319c738: extract.js no longer exports the Gemini helpers that only the old caption fetch used.
  • npm test: 18/19 pass. test/render.test.js needs an Eschults/cookbook checkout this session cannot reach, and it fails on main too. The live hand-run on 93923d7 passed.

Left for you

  • The unused env var and its comment in .github/workflows/add-recipe.yml (inline). Harmless, but repo rules mean workflow files need your approval to edit.
  • Not checked: whether Instagram's og:description shows the full caption on very long posts. The live run used one reel.

Session: https://claude.ai/code/session_01PqRBbb6QeVTurq7z7t8zkw

claude --teleport session_01PqRBbb6QeVTurq7z7t8zkw

Generated by Claude Code

env:
# Only Chromium is used; the next step fetches just that one, with
# the system libraries it needs to actually launch headless.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nothing, and it's left for you. playwright 1.63.0 has no install script (its package.json has no scripts, and the lockfile doesn't flag one), so npm ci never downloads a browser to skip. The next step's npx playwright install --with-deps chromium does all the work. The comment above says otherwise, so removing both would be clearer. It's harmless as it stands, and repo rules mean I don't edit workflow files without your approval.


Generated by Claude Code

Comment thread README.md

```bash
npm install
npx playwright install chromium

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 884a8d5. The README said npm install downloads the browser, but playwright has no install script, so a local run with only a URL would fail at chromium.launch() with "Executable doesn't exist".


Generated by Claude Code

@Eschults
Eschults merged commit 4456655 into main Sep 26, 2026
@Eschults
Eschults deleted the claude/amazing-cannon-zzdbek branch September 26, 2026 11:55
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.

Add step to copy paste Instagram post caption from URL

2 participants