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
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:
1 parent
45183c725f
commit
caed0cbaa0
18 files changed
+743
-16
No files matched your search
@@ -86,6 +86,8 @@ would catch is a change nothing checks here.
|
||||
- `exercises.js` / `exercises-data.js` — the exercise library (1,324 built-ins + user-defined).
|
||||
- `vitals-view.js` — the Apple Health metric catalogue and card model (labels, units, which
|
||||
aggregate a card shows, workout rows). The server stores numbers; this decides how they read.
|
||||
- `music.js` — reading and validating the Apple Music share links a profile keeps. Apple has no
|
||||
API for somebody else's public playlists, so a playlist here is a link, not an integration.
|
||||
- `api.js` — the only place that talks to the backend (`fetch` wrapper, session cookie flows).
|
||||
- CONTRIBUTING.md is explicit: **anything that decides what you lift next, or reads a logged
|
||||
session back, is a pure helper here with a unit test beside it** — not verifiable by
|
||||
@@ -119,10 +121,12 @@ gated by env vars: `ADMIN_UIDS` (admin dashboard), `INVITE_ONLY` (signup needs a
|
||||
`data/audit.log` (JSONL) for sign-in/admin events. Web Push (`web-push`, VAPID keys
|
||||
auto-generated into `data/vapid.json`) drives rest-timer-over and day-reminder notifications.
|
||||
|
||||
`vitals.js` sits beside `server.js` as the only non-`server.js` module with real logic on the API
|
||||
side: HAE parsing, the idempotent merge (the reason a 5-minute automation does not double a day of
|
||||
steps) and retention. `server.js` owns the bytes; that file owns the arithmetic, which is why it is
|
||||
testable without a phone.
|
||||
`vitals.js` and `music.js` sit beside `server.js` as the modules with real logic on the API side:
|
||||
HAE parsing, the idempotent merge (the reason a 5-minute automation does not double a day of steps)
|
||||
and retention in the first; reading what a public Apple Music page says about itself, behind a host
|
||||
allowlist, in the second. `server.js` owns the sockets; those files own the parsing, which is why
|
||||
they are testable without a phone or a network. Both are listed in the Dockerfile's `COPY` — an
|
||||
import of a file that is not copied there is a container that boots into ERR_MODULE_NOT_FOUND.
|
||||
|
||||
### MCP server (`mcp/src`)
|
||||
|
||||
|
||||
Reference in new issue
Block a user