Skip to content

Repository files navigation

Apple Music + Spotify Now Playing

A live now-playing card for GitHub markdown. It merges Apple Music and Spotify into one badge, and it's just a small Node server, so it'll run anywhere you can run Docker. I host mine on Coolify because that's what I already had running.

Live now-playing card

That's my actual card, live. Reload the page and it'll show whatever I'm playing right now (or the last thing I played, if nothing's on).

![Now Playing](https://nowplaying.example.com/now-playing.svg)

How it works

Music.app  ──AppleScript──▶  launchd agent ─┐
  (your Mac)                   (your Mac)    ├─▶ your server ──▶ GitHub <img>
Spotify Web API ◀──── server polls ─────────┘   (merges + renders SVG)

Two sources feed one card. Whichever one is actually playing wins. If both are paused, the card shows whoever played more recently, not a fixed priority order. I shipped "Apple Music always wins" first and had to rip it out once I noticed Apple's own heartbeat kept a stale paused track alive indefinitely, quietly burying whatever Spotify had just finished playing. The accent color still tracks the source: green while Spotify's showing, red for Apple Music.

GitHub strips JavaScript and iframes from rendered markdown, so an <img> is the only element that can show content that changes over time. That's why the widget is a server-rendered SVG with the animation baked in via SMIL, which does run when the SVG loads as an image. The progress bar keeps advancing in your browser after the image loads, so a single fetch stays accurate for the rest of the track.

And Apple never shipped a public now-playing API for either desktop app. MusicKit only reports what a user plays inside your own web app, not what's on their machine. So there's a small local agent that pushes state to the server instead: on macOS it polls Music.app over AppleScript; on Windows, where Apple Music has no scripting hooks at all, it reads Windows' System Media Transport Controls instead.

Spotify's easier, since it does have a real API for this. The server holds a refresh token and polls /me/player/currently-playing directly, no agent needed, and it catches playback from any device on the account, phone included.

Documentation

Same pages are also up on the wiki if you'd rather browse with a sidebar.

About

Live now-playing card for GitHub markdown; merges Apple Music + Spotify into one animated SVG

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages