Skip to content

Finish media library: live YouTube auto-pull - #24

Merged
samanyugoyal2010 merged 11 commits into
mainfrom
feature/youtube-media-autopull
Sep 6, 2026
Merged

Finish media library: live YouTube auto-pull#24
samanyugoyal2010 merged 11 commits into
mainfrom
feature/youtube-media-autopull

Conversation

@735meis

@735meis 735meis commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Finishes out @samanyugoyal2010's media library scaffold (codex/add-media-library) so it's production-ready:

  • YouTube auto-pull (lib/youtube.ts): pulls the channel's recent uploads live via the YouTube Data API v3, cached with hourly ISR revalidation — post a new video and it shows up on /media and the homepage teaser on its own, no code change or redeploy.
  • Fails soft everywhere: missing key/channel, a bad API response, or a network error all just return an empty list (falls back to the existing "new videos are on the way" empty state) rather than throwing for every visitor.
  • getMediaItems() / getFeaturedMedia() now merge hand-curated entries (MEDIA_ITEMS — still how Instagram gets added, since IG has no equivalent auto-pull yet) with the live YouTube fetch, newest first. The homepage's 3 featured slots auto-fill from the latest uploads unless exactly 3 items are manually pinned.
  • Instagram filter tab hidden on /media for now (per request) until real Instagram entries exist — everything else Instagram-related (types, validation, card rendering) is untouched, so it's a one-line change to bring back.
  • .env.example documents the new YOUTUBE_API_KEY / YOUTUBE_CHANNEL_HANDLE / YOUTUBE_CHANNEL_ID vars, following the same optional/fail-soft convention as Clerk/Supabase/Resend.

Verification

  • npm run typecheck, npm run lint, npm run build all pass
  • Smoke-tested against the real @CodeWithPurposeTeam channel end-to-end (both channels.list and playlistItems.list) — confirmed the app correctly renders the channel's live uploads on /media
  • Standalone test of the mapping/sort/dedupe logic against realistic (and deliberately malformed) API response shapes

🤖 Generated with Claude Code

samanyugoyal2010 and others added 11 commits September 5, 2026 21:10
Server-only fetch layer that resolves a channel's uploads playlist (by
handle or ID) and pulls its recent videos, cached with hourly ISR
revalidation. Fails soft everywhere — no key, no channel, a bad
response, or a network error all just return an empty list rather than
throwing, so a YouTube outage can't take down the site.
YOUTUBE_API_KEY, YOUTUBE_CHANNEL_HANDLE, YOUTUBE_CHANNEL_ID — all
optional, matching the Clerk/Supabase/Resend convention of failing soft
when unset rather than breaking the build.
publishedAt will drive sort order once fetched YouTube uploads are
merged in. MEDIA_ITEMS's role narrows to hand-curated entries — mainly
Instagram, plus pinning a specific YouTube video — now that YouTube
itself is sourced live.
getMediaItems() is now async: it fetches the channel's recent uploads,
de-duplicates against hand-curated entries (curated wins on id
collisions), and returns everything newest-first.
getFeaturedMedia() now falls back to the 3 most recent items across
the merged library when nothing in MEDIA_ITEMS is manually marked
featured, so the homepage teaser stays current on its own. A manual
pin of exactly 3 still wins outright.
Follows getFeaturedMedia() becoming async.
Follows getMediaItems() becoming async. This is the last piece needed
for the auto-pull change to build cleanly end to end.
Instagram support (types, validation, card rendering) is untouched —
just not selectable as a filter until real Instagram entries are
added to MEDIA_ITEMS.
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
new-cwp Ready Ready Preview Sep 6, 2026 8:08am UTC

@samanyugoyal2010 samanyugoyal2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Look's good @735meis nice work. Thanks for picking up the initial scaffold I had

@samanyugoyal2010

Copy link
Copy Markdown
Contributor

@735meis I am merging

@samanyugoyal2010
samanyugoyal2010 merged commit 6ff6957 into main Sep 6, 2026
3 checks passed
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.

2 participants