Skip to content

Repository files navigation

YouTube Music for VS Code (unofficial)

Play YouTube Music without leaving your editor. Search, browse your library and the home feed, queue playlists and albums, like songs — all from a sidebar view, with audio played natively through mpv (no browser tab, no embedded player).

Unofficial. This project is not affiliated with or endorsed by YouTube or Google. It uses unofficial APIs and is intended for personal use — see Caveats.

Features

  • Search songs; click to play, results become the play queue
  • Home tab: your personalized feed when signed in (mixes, Listen Again), generic discover feed otherwise
  • Library tab: your playlists, including private ones
  • Artist and album pages — click any artist/album name to drill in
  • Like / un-like the current track (syncs with your account)
  • Seek bar, volume, mute
  • Status bar controls with the current track title
  • Keyboard media keys (play/pause, next, previous)
  • Fast track starts: stream URLs are pre-resolved and the next queued track is prefetched while you listen

Requirements

  • macOS (binary discovery currently assumes Homebrew paths; PRs welcome for Windows/Linux)

  • VS Code 1.85+

  • mpv and yt-dlp:

    brew install mpv yt-dlp

Install

There's no marketplace listing — grab the .vsix from the latest release and install it:

code --install-extension ytmusic-vscode-<version>.vsix

(or in VS Code: command palette → Extensions: Install from VSIX… and pick the downloaded file).

Then click the music-note icon in the activity bar, or run YouTube Music: Open Player from the command palette.

Build from source

git clone https://github.com/ronanbradley/vscode-youtube-music.git
cd vscode-youtube-music
npm install
npx @vscode/vsce package
code --install-extension ytmusic-vscode-*.vsix

Run from source (development)

npm install
npm run watch

Open the folder in VS Code and press F5 to launch an Extension Development Host.

Signing in

Search and the discover feed work without an account. Your library, the personalized home feed and likes need one:

  1. Click Log in in the player (top right).
  2. Pick a browser you're already signed in to music.youtube.com with.
  3. On macOS, approve the one-time Keychain prompt (Chromium browsers) — yt-dlp uses it to decrypt the browser's cookie store. Safari instead needs VS Code to have Full Disk Access.

The extension lifts your existing session cookie from the browser — there's no password entry and no OAuth dance. You can also paste a cookie header manually (the picker's last option) if you prefer.

Where it goes: the cookie is stored in VS Code's secret storage (the macOS Keychain) and is only ever sent to YouTube. It is redacted from all logs. When Google rotates the cookie, the extension silently re-extracts it from the same browser. Log out deletes it.

Why cookies and not OAuth: YouTube Music's API rejects OAuth device-flow tokens (they're issued for the TV client) with HTTP 400 on search and library endpoints. Cookie auth is what other YouTube Music libraries (e.g. ytmusicapi) use as well.

How it works

sidebar webview (UI only)
        │
extension host
        ├─ youtubei.js ── search / browse / likes (InnerTube)
        └─ mpv ────────── audio, controlled over its JSON IPC socket
              └─ yt-dlp ── stream URL resolution

VS Code webviews cannot play remote media (the webview service worker blocks media fetches, and even YouTube's official embed cannot start playback inside the webview's iframe chain), so audio is delegated to a headless mpv process owned by the extension host. The webview is purely UI; closing or hiding it doesn't interrupt playback.

Track starts are kept fast by resolving stream URLs directly with yt-dlp's Android client (~1.5 s instead of ~3.5 s for the default multi-client resolution), caching them, and prefetching the next queued track.

Troubleshooting

  • "mpv IPC socket did not appear" — mpv isn't installed or isn't at a Homebrew path. brew install mpv, then reload the window.
  • A track won't play / long delay after weeks of uptime — cached stream URLs can expire; the player falls back to full resolution automatically. If a track persistently fails, it's usually region- or age-restricted.
  • Library shows an error — your cookie went stale and silent refresh failed (e.g. you logged out of the browser). Log in again.
  • Safari login fails — grant VS Code Full Disk Access in System Settings → Privacy & Security, or use a Chromium browser.
  • For request-level debugging, launch VS Code from a terminal with YT_DEBUG=1. Authorization and cookie headers are redacted.

Caveats

  • Built on unofficial APIs (InnerTube via youtubei.js, and yt-dlp). YouTube changes things without notice; expect occasional breakage until the libraries catch up.
  • Streaming this way bypasses YouTube's player and ads and is against YouTube's Terms of Service. Use at your own risk, ideally with a YouTube Music Premium subscription, and don't redistribute this as a service.
  • macOS only for now.

License

MIT

About

Unofficial YouTube Music player for VS Code. Search, library, playlists and likes, with native audio via mpv + yt-dlp.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages