fix(radio): Support Chocolatemoo audio handoffs
Summary
Chocolatemoo serves playable YouTube audio through a redirect to a Companion server. The provider verifier rejected that handoff before playback could start. Add Chocolatemoo as the fourth fallback and make media redirects an explicit provider capability.
resolve YouTube audio
- reject the Companion redirect
+ follow media redirects only for an opted-in provider
+ validate starting/final origins and public URLs
+ verify the audio type, byte range, and nonempty body
+ return the verified final Companion URL to the player
API/text requests and providers without the capability retain redirect: error. Only Chocolatemoo opts in, using its frontend and six explicit Companion origins. The pool deadline grows from 25 to 30 seconds to accommodate five providers; each provider still gets five seconds.
Redirect policy: browser Fetch hides manual redirect destinations. Automatic redirect following therefore trusts Chocolatemoo's intermediate routing. The origin list and URL/DNS checks validate the starting and final URLs; they do not inspect or prevent intermediate requests. Rejected final responses are canceled. This is a scoped browser transport policy, with no new proxy, credentials, infrastructure, or player changes.
Evidence
- Before:
bun test packages/platforms/src/youtube/provider.test.ts -t 'verifies the media handoff'— both adapter cases failed because their stream resolution rejected the simulated browser redirect.
After: both cases return the verified Companion URL, including the item's playback metadata. - Review follow-up: interrupted final companion DNS validation now preserves retryable
timeoutand non-retryableabortedinstead of a retryable schema error; ordinary validation failures retain their classification. The 503 regression asserts both HTTP code and status, and the changed helpers document their contracts. - Regression coverage also checks API redirects remain disabled, unapproved starting/final origins, ports and credentials, private DNS, missing response URLs, response cancellation, invalid audio/ranges, outages, and curated fallback wiring.
- Previous Chrome feasibility probes from
radio.avoid.questretrieved recent and older audio, produced nonzero Web Audio samples, and successfully sought to 90 seconds. The maintainer subsequently tested the PR preview at18d8a827and reported that it works well. - Passed:
bun run check,bun run typecheck,bun run --filter @avoid.quest/platforms test(383 tests),bun run --filter @avoid.quest/radio test(3,572 tests), andbun run --filter @avoid.quest/radio build. The provider suite also covers parent cancellation and timeout during final companion DNS validation, response cleanup, and exact HTTP 503 classification.
Manual validation
- Open the Cloudflare preview from the PR deployment comment.
- To force this fallback, temporarily block requests to
pipedapi.wireway.ch,yt.omada.cafe,invidious.nikkosphere.com, andy.com.sbusing browser DevTools request blocking. - In DJ mode, resolve a recent, public, non-live YouTube track. Confirm metadata comes from
yt.chocolatemoo53.comand the ranged audio probe/player use ayt-compN.chocolatemoo53.comURL. Check playback, seeking, effects, crossfading, and cue/master routing. - Remove the request-blocking rules and confirm normal playback/failover. Relay availability and repeated extraction remain external dependencies; this PR does not establish an uptime guarantee.
Merge Danger
Door: two-way
Code/configuration only. Opt-in automatic media redirects introduce the intermediate-routing trust described above. The maintainer reports successful preview validation of the initial patch. The review follow-up preserves cancellation/timeout classification during final companion DNS validation; it does not change successful media handoffs.
Blast Radius: playback
Shared YouTube provider verification supports the capability; only the newly curated Chocolatemoo fallback enables it.
Changelog: YouTube playback can use another relay when other providers fail.
Summary by cubic
Adds Chocolatemoo as a fourth YouTube fallback relay and makes media redirects an opt-in provider capability. The provider serves audio through a companion-server redirect that the verifier previously rejected; now the verified final companion URL returns to the player.
Behavior
- Only Chocolatemoo opts in, using its frontend and six companion origins; other providers and all API/text requests keep rejecting redirects.
- Starting and final URLs must match the curated origins and pass public-URL and DNS validation; the body must be audio with a valid byte range.
- Browser Fetch governs intermediate hops since manual redirects hide destinations, so the operator's routing is trusted; rejected final responses are canceled.
- The pool deadline grows from 25 to 30 seconds to fit five providers at five seconds each.
Summary by CodeRabbit
- New Features
- Added another YouTube provider option, expanding available sources for video playback.
- Bug Fixes
- Improved stream resolution when a provider redirects media to a companion host, helping ensure playback uses the verified media URL. Other provider requests continue to reject redirects.