feat(youtube): auto-transition broadcast to live (no more "Preparing stream")#30
Merged
Conversation
…stream")
When the egress pushes a clean continuous stream to YouTube, YouTube still
leaves the broadcast in ready/testing ("Preparing stream") until someone clicks
Go Live (unless Auto-start is on). This adds the YouTube Live API integration to
force it live automatically.
- OAuth: /api/youtube/auth + /api/youtube/callback (Google consent, offline
access). Refresh token stored in new youtube_credentials table (RLS-locked,
service-role only — token never reaches the client).
- lib/youtube.ts: token exchange/refresh + liveBroadcasts list/transition.
- lib/youtubeAutoLive.ts: on egress start to a youtube.com URL, poll the user's
broadcasts (~90s) and transition the first ready/testing one to live.
Fire-and-forget; never throws or delays egress start; no-op unless the user
connected YouTube.
- /api/youtube/status + /disconnect, and a "Connect YouTube" card in Settings.
Requires Railway env GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET and the migration
applied. Dormant until configured. 8 new tests; lint + tsc clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The egress pushes a clean, continuous stream to YouTube, but YouTube leaves the broadcast in
ready/testing("Preparing stream") until someone clicks Go Live (unless Auto-start is on). This integrates the YouTube Live API to force it live automatically when you start streaming.How
/api/youtube/auth→ Google consent (offline access) →/api/youtube/callbackstores the refresh token in a newyoutube_credentialstable. RLS-locked with no policies — service-role only, so the token never reaches the client.lib/youtube.ts: token exchange/refresh +liveBroadcasts.list/liveBroadcasts.transition.lib/youtubeAutoLive.ts: on egress start to ayoutube.comURL, poll the user's broadcasts for ~90s and transition the firstready/testingone tolive. Fire-and-forget; never throws or delays egress start; no-op unless the user connected YouTube./api/youtube/status+/disconnect, and a "Connect YouTube" card in Settings.Activation (not automatic — needs config)
pairux.comservice:GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET.youtube_credentialsmigration.Dormant and safe until configured (the egress hook is gated on
youtubeOAuthConfigured()+ a stored token, all wrapped in try/catch).Tests
8 new (token URL/exchange, broadcast filtering to ready/testing, transition endpoint, auto-transition happy-path / not-connected / never-throws). Lint + tsc clean; 30 tests green across the touched areas.
🤖 Generated with Claude Code