Podcasts: en español solamente, y se acuerdan de dónde ibas
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

Música tiene una sección **Podcasts**: programas por categoría —Salud y fitness,
Deporte, Comedia, Noticias, Historia, Crímenes reales, Ciencia, Tecnología,
Sociedad y cultura, Negocios, Ficción, Educación, Música, Ocio— que suenan mientras
entrenás y siguen donde los dejaste. Sin dependencias nuevas y sin clave de API: el
directorio de Apple es público.

**En español se comprueba, no se supone.** La tienda dice dónde se *vende* un
podcast, no en qué idioma está —en el ranking español de comedia hay uno en catalán
y en el argentino uno en inglés—, así que se lee el `<language>` del feed de cada
programa (los primeros 64 KB, con una petición `Range`: el idioma está en las
primeras líneas) y se descarta lo que no sea español. Un feed sin etiqueta se queda:
feeds genuinamente españoles la omiten, y tirarlos por una omisión sería sacar
podcasts buenos de la lista. La respuesta cuenta cuántos quedaron afuera y por qué
(`skipped`), así que una lista corta nunca es un misterio, y abrir un programa en
otro idioma se contesta con `spanish:false` en vez de con una lista vacía.

Es la otra mitad de la radio y es lo contrario en todo lo que le importa al
reproductor: un podcast es un **archivo** —tiene principio, final y un minuto en el
que ibas—. Por eso hay un módulo de reglas puras (`lib/podcast-view.js`: dónde
retomar, qué cuenta como escuchado, cuál sigue, cuántas posiciones se guardan) y
por eso `lib/radio-player.js` pasa a ser `lib/player.js`: **un solo elemento de
audio** para las dos cosas, que es lo que impide que una emisora y un episodio suenen
a la vez. La barra crece línea de progreso, −15 s, +30 s, siguiente episodio y reloj;
la posición se guarda por perfil (con tope de 200, lo más nuevo primero) en pausa, al
parar, al terminar y cuando la app se va al fondo, porque con la pantalla bloqueada
iOS suspende los temporizadores y un guardado sólo desde el tick perdería lo
escuchado con el teléfono guardado. Media Session muestra episodio, programa y
progreso en la pantalla bloqueada.

Nada se descarga y nada pasa por el servidor: el episodio llega como la URL del
`enclosure` y el audio va de quien lo publica al teléfono. Acá no hay lista blanca
posible —un feed vive en cualquier host—, así que la puerta es **https, host real y
nunca una dirección privada**, comprobada en la URL y en dónde terminó el pedido, con
el cuerpo leído a tope y la conexión cortada al llegar: este contenedor vive adentro
de una casa.

Verificado con datos reales: 20 programas en español por categoría (idiomas es, es-ES,
es-mx), un feed de 40 episodios parseado, un feed en inglés contestado como
`spanish:false` y la dirección de metadatos rechazada con 400 sin hacer el pedido.

Fuera de los podcasts: la página de la API ocultaba `health` y `music` enteras —el
generador sólo dibuja las secciones de su tabla de etiquetas—, así que ahora están,
con radio y podcasts incluidas.
This commit is contained in:
dsantillan committed 2026-09-23 21:11:20 -04:00
1 parent a3e13df279
commit 22654c61fc
31 files changed
+3687 -360

No files matched your search

+21 -11
View File
@@ -28,7 +28,7 @@ media/ exercise img/gif, gitignored, fetched at runtime by the `media` compo
website/ static marketing site (plain HTML/CSS/JS) — not deployed for this fork; built by hand
when someone wants it (node scripts/build-api-docs.mjs fills in api.html).
docs/ SELF_HOSTING.md, MOBILE.md, AI_COACH.md, HEALTH.md (Apple Health ingest),
RADIO.md (live stations).
RADIO.md (live stations), PODCASTS.md (Spanish-language episodes).
```
## Commands
@@ -90,10 +90,15 @@ would catch is a change nothing checks here.
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.
- `radio-player.js` — the single `<audio>` element and Media Session, held **outside React** on
purpose: an element owned by a component unmounts with it, which is how a player stops when
somebody changes screens. `play()` is called synchronously from the tap because iOS only allows
audio to start inside a gesture — see `docs/RADIO.md` before touching any of it.
- `player.js` — the single `<audio>` element and Media Session, for both the radio and the
podcasts, held **outside React** on purpose: an element owned by a component unmounts with it,
which is how a player stops when somebody changes screens. `play()` is called synchronously from
the tap because iOS only allows audio to start inside a gesture, and one element is what keeps a
station and an episode from ever playing at once. See `docs/RADIO.md` and `docs/PODCASTS.md`
before touching any of it.
- `podcast-view.js` — where to resume, what counts as heard, what comes next, and how many
positions to keep. Pure, because "resumed into the last twenty seconds" and "marked heard after
five minutes" are bugs nobody reports — they just stop using the feature.
- `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
@@ -127,12 +132,17 @@ 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`, `music.js` and `radio.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; the live-station directory — SomaFM, Radio Paradise and
radio-browser — in the third, which is also where the rule lives that **audio is never proxied**: the
api hands out a resolved stream URL and the phone talks to the station directly. `server.js` owns the
`vitals.js`, `music.js`, `radio.js` and `podcasts.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; the live-station directory — SomaFM, Radio Paradise
and radio-browser — in the third; and Apple's podcast directory plus a tolerant RSS reader in the
fourth, where the two rules that matter are **Spanish only** (checked in each feed's own
`<language>`, not assumed from the storefront) and **no private address is ever fetched** (a feed can
live anywhere, so there is no allowlist to hide behind: https, a real host, and a check of where the
request ended up as well as where it was pointed). All of them hold the same line about audio:
**nothing is proxied**. The api hands out a resolved stream URL or the publisher's own episode URL,
and the phone talks to the station or the publisher directly. `server.js` owns the
sockets; those files own the parsing, which is why they are testable without a phone or a network.
All of them 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.