Skip to content

feat: download NotebookLM infographics → upload to Sanity assets#616

Merged
codercatdev merged 3 commits intodevfrom
feat/infographic-download-upload
Mar 5, 2026
Merged

feat: download NotebookLM infographics → upload to Sanity assets#616
codercatdev merged 3 commits intodevfrom
feat/infographic-download-upload

Conversation

@codercatdev
Copy link
Contributor

Summary

Downloads infographic images from NotebookLM and uploads them to Sanity assets, making them available as first-class image references in the CMS — reusable for blog posts and video b-roll.

Changes

1. Schema: sanity/schemas/documents/automatedVideo.ts

  • Added infographics array field (visible, not hidden) between shortUrl and renderData
  • Each item is an image type with hotspot, alt text, and caption fields
  • Alex wants these reusable for blog posts, so they're visible in the Studio

2. Route: app/api/cron/check-research/route.ts

  • Import writeClient from @/lib/sanity-write-client
  • In stepInfographicsGenerating, replaced the URL-only collection loop with:
    1. Get auth-gated URL via getInfographicUrl()
    2. Download PNG with authenticated fetch using NotebookLM cookies
    3. Upload to Sanity via writeClient.assets.upload('image', buffer, { filename })
    4. Build _type: 'image' refs for the infographics array field
    5. Store Sanity CDN URLs in researchData.infographicUrls for backward compat
  • Each infographic is wrapped in try/catch for graceful degradation
  • Patch includes both infographics array (image refs) and researchData (CDN URLs)

3. Client: lib/services/notebooklm/client.ts

  • Added getCookieHeader() method to expose the auth cookie header for authenticated image downloads

Before → After

Before: Stored auth-gated lh3.googleusercontent.com URLs that expire and require Google auth to access.

After: Images are downloaded and uploaded to Sanity CDN — permanent, public URLs. Image refs stored in the infographics array field for direct use in Sanity Studio, blog posts, and Remotion compositions.

Verification

  • npx tsc --noEmit — clean for all modified files (only pre-existing error in unrelated sanity-revalidate route)
  • Schema field positioned correctly: after shortUrl, before renderData
  • Error handling: try/catch around each infographic download/upload
  • Backward compat: CDN URLs still stored in researchData.infographicUrls

Miriad and others added 3 commits March 5, 2026 07:02
…wnloads

Co-authored-by: research <research@miriad.systems>
… reusable for blog posts)

Co-authored-by: research <research@miriad.systems>
… check-research

- Import writeClient from sanity-write-client
- Download PNGs with authenticated fetch using NotebookLM cookies
- Upload to Sanity via writeClient.assets.upload()
- Store image refs in infographics array field on doc
- Keep backward-compat CDN URLs in researchData.infographicUrls
- Graceful error handling per infographic (try/catch)

Co-authored-by: research <research@miriad.systems>
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
codingcat-dev Ignored Ignored Mar 5, 2026 7:04am

@codercatdev codercatdev merged commit e28b8a6 into dev Mar 5, 2026
2 of 3 checks passed
@codercatdev codercatdev deleted the feat/infographic-download-upload branch March 5, 2026 12:06
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.

1 participant