YTMDesktop2
Internals

Thumbnail cache

Disk cache and ytmd-thumb protocol for album art

YTMDesktop2 caches YouTube Music album art on disk and serves it to app chrome over ytmd-thumb://.

Who uses it

SurfaceRole
Tray viewCover art in the tray popup (toAppThumbUrl)
Mini player (removed in 1.4.0)Cover art in the compact window (toAppThumbUrl)
Track accentPalette / accent color from the cached image buffer
macOS Touch BarArtwork bytes via getBuffer

The embedded YouTube Music webview does not use this cache — it loads CDN thumbs itself.

Why it exists

Tray view is a separate window from the YouTube Music webview. Loading CDN URLs directly often fails without the logged-in session cookies and browser-like headers. The cache:

  1. Fetches thumbs through the YouTube Music session (cookies, user agent, referer).
  2. Stores image bytes under the app user-data folder.
  3. Serves them back to tray view and other app UI over ytmd-thumb://.

How tray view loads art

Remote URLs are mapped with toAppThumbUrl():

  • HTTPS thumbs on googleusercontent.com, ggpht.com, or ytimg.comytmd-thumb://i/<base64url>
  • Anything else stays as the original URL

The main process handles ytmd-thumb on the default session (shared by tray view) and returns cached bytes, or fetches once then caches.

Storage

ItemLocation / limit
Cache directory<userData>/thumb-cache/
Entry keySHA-256 of the remote URL
Files per entryBinary blob + encrypted .json meta
Max entries200 (oldest pruned)
Meta encryptionAES-256-CBC via thumb-cache.key

Meta stores URL, MIME type, size, and save time. Invalid or decrypt-failed meta triggers a refetch.

Fetch behavior

  • Prefer youtubeView session fetch so Google sees the logged-in client.
  • Spoof image Sec-Fetch-* / Sec-CH-UA headers similar to a real Music page request.
  • Fall back to net.fetch if session fetch fails.
  • In-flight requests are deduped per URL key.
  • Successful responses are served with long-lived Cache-Control to the renderer.

On this page