Commands

sonos play youtube

sonos play youtube

Uses yt-dlp to resolve a YouTube URL to a temporary direct audio URL, sets that URL on the group coordinator, and starts playback.

For day-to-day playback, prefer sonos play-url. It runs a short-lived local proxy, lets yt-dlp handle HLS-only YouTube media, transcodes to a Sonos-safe MP3 stream, supports YouTube / YouTube Music playlist URLs, and provides cleaner metadata in the Sonos app.

#Synopsis

sonos play youtube <url> --name "<Room>" [--yt-dlp <path>] [--media-format <selector>] [--title "<title>"] [--radio]

#Requirements

  • yt-dlp must be installed and available on PATH, or passed with --yt-dlp.
  • The Sonos speaker must be able to fetch the resolved googlevideo.com URL directly.
  • Resolved YouTube URLs expire; rerun the command if playback starts failing later.
  • Some videos only expose HLS audio that Sonos or direct ffmpeg fetching may reject. Use sonos play-url for those.

#Flags

FlagWhat it does
--yt-dlp stringPath to yt-dlp (default: yt-dlp).
--media-format stringyt-dlp media selector. Defaults to an AAC/M4A-first selector that Sonos is likely to play.
--title stringOverride the display title (defaults to the YouTube title).
--radioForce radio-style playback for the resolved stream.

#Examples

sonos play youtube --name "Kitchen" "https://www.youtube.com/watch?v=-n_rdQIVahw"

For a URL that includes a playlist or YouTube radio queue, sonoscli plays only the selected/current video:

sonos play youtube --name "Kitchen" "https://www.youtube.com/watch?v=-n_rdQIVahw&list=RD-n_rdQIVahw&start_radio=1"

To enqueue a YouTube / YouTube Music playlist, use play-url instead:

sonos play-url --name "Kitchen" "https://music.youtube.com/playlist?list=PL..."
sonos play-url --name "Kitchen" --playlist "https://www.youtube.com/watch?v=-n_rdQIVahw&list=PL..."

If Sonos rejects normal track-style playback, retry as a radio stream:

sonos play youtube --name "Kitchen" --radio "https://www.youtube.com/watch?v=-n_rdQIVahw"

#How it works

The command runs yt-dlp --no-playlist -f <selector> -j <url>, reads the selected format URL and title from JSON, then calls AVTransport.SetAVTransportURI followed by AVTransport.Play.