Skip to content

feat(youtube): auto-transition broadcast to live (no more "Preparing stream")#30

Merged
ralyodio merged 1 commit into
masterfrom
feat/youtube-auto-golive
Jun 23, 2026
Merged

feat(youtube): auto-transition broadcast to live (no more "Preparing stream")#30
ralyodio merged 1 commit into
masterfrom
feat/youtube-auto-golive

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

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

  • OAuth: /api/youtube/auth → Google consent (offline access) → /api/youtube/callback stores the refresh token in a new youtube_credentials table. 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 a youtube.com URL, poll the user's broadcasts for ~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.

Activation (not automatic — needs config)

  1. Railway env on the pairux.com service: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET.
  2. Apply the youtube_credentials migration.
  3. User clicks Connect YouTube in Settings (one-time OAuth).

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.

Web (apps/web) — deploys to Railway on merge.

🤖 Generated with Claude Code

…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>
@ralyodio ralyodio merged commit 0d1a7c0 into master Jun 23, 2026
@ralyodio ralyodio deleted the feat/youtube-auto-golive branch June 23, 2026 11:28
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

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