Música: a playlist screen per profile, with Apple's limits stated plainly
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

The idea was "each person types their Apple Music username and their public playlists
appear". Apple does not allow that, and it is worth writing down rather than discovering
later: there is no API for another person's public playlists — their own developer forums
answer that request with "you can't" (threads 692941 and 123894) — and a profile page is
rendered by JavaScript with nothing behind it to call. MusicKit offers the catalog and the
*signed-in* user's own library, and the second needs an Apple Developer Program membership
for a developer token plus a Music-User-Token per person: a private key and a third-party
secret in an app that holds none, to fetch something other than what was asked for.

What a self-hosted app can do is the share link, which every playlist has: Music → Share →
Copy Link. So the Música screen (next to Salud in Home's header, plus a section in Settings)
keeps a list of them per profile, in the profile document like the routines — so they sync to
the other devices and travel in a backup — and tapping one opens it in Apple Music on the
iPhone. The username is a link to the person's public profile.

The list is nicer than a column of URLs because the API reads each link's public page for a
title, artwork and track count. That is scraping, so it is built to lose: a page that says
nothing leaves the card showing the name its owner typed, and nothing on the screen depends
on it. `POST /api/music/lookup` is host-allowlisted to Apple's music hosts — https only,
checked again on the URL a redirect lands on — because the api container sits on the same
network as everything else the owner runs, and a route that fetches whatever it is handed is
a request-forgery lever. That boundary has its own tests, including the LAN addresses it
must refuse.

The parsing lives in api/music.js rather than in both halves: two copies of a parser kept in
step by hand is a bomb, and this is the same shape as vitals.js. It is in the Dockerfile's
COPY for the same reason vitals.js had to be.
This commit is contained in:
dsantillan committed 2026-09-23 12:22:01 -04:00
1 parent 45183c725f
commit caed0cbaa0
18 files changed
+743 -16

No files matched your search

+4 -4
View File
@@ -53,10 +53,10 @@ RUN npm ci --omit=dev --omit=optional && npm cache clean --force
# Every local module server.js imports, listed rather than `COPY . .` so a stray file in api/
# (a test, a script, a stray JSON) cannot reach the published image. vitals.js joined the list
# with the Apple Health ingest — an import of a file that is not copied here is a container that
# boots straight into ERR_MODULE_NOT_FOUND, which is exactly what the first health build would
# have done.
COPY server.js push-messages.js verify-error.js vitals.js ./
# with the Apple Health ingest and music.js with the Música one — an import of a file that is not
# copied here is a container that boots straight into ERR_MODULE_NOT_FOUND, which is exactly what
# the first health build would have done.
COPY server.js push-messages.js verify-error.js vitals.js music.js ./
COPY coach ./coach
ENV NODE_ENV=production
ENV PORT=3000