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
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:
1 parent
a3e13df279
commit
22654c61fc
31 files changed
+3687
-360
No files matched your search
+185
-4
@@ -90,9 +90,10 @@ tags:
|
||||
per profile, write-only for the phone's ingest key
|
||||
- name: music
|
||||
description: >-
|
||||
Música — reading a public Apple Music page for a saved playlist's card, and the live radio
|
||||
station directory. Audio is never proxied by this server: the list carries resolved stream
|
||||
URLs and the phone talks to the station directly.
|
||||
Música — reading a public Apple Music page for a saved playlist's card, the live radio station
|
||||
directory, and the Spanish-language podcast directory. Audio is never proxied by this server:
|
||||
a station arrives as a resolved stream URL, an episode as the publisher's own file URL, and
|
||||
the phone talks to the station or the publisher directly.
|
||||
- name: admin
|
||||
description: Admin dashboard — requires an admin session (`ADMIN_UIDS` or `admin:true`)
|
||||
|
||||
@@ -161,7 +162,7 @@ paths:
|
||||
server", never as "supports everything".
|
||||
items:
|
||||
type: string
|
||||
enum: [vitals, vitals.hours, vitals.receipt, music.lookup, radio, insights]
|
||||
enum: [vitals, vitals.hours, vitals.receipt, music.lookup, radio, podcasts, insights]
|
||||
coach:
|
||||
type: object
|
||||
description: Present only when the AI Coach is configured on this instance.
|
||||
@@ -1040,6 +1041,136 @@ paths:
|
||||
description: No such station — an unknown `src`, or an `id` that is not a plain id.
|
||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||
|
||||
/api/podcasts:
|
||||
get:
|
||||
tags: [music]
|
||||
operationId: podcastsGet
|
||||
summary: Spanish-language podcast shows for a category
|
||||
description: |
|
||||
What the **Podcasts** section of the Música screen draws. Apple's public podcast directory
|
||||
(no API key, no account) supplies the storefront charts per category and the feed URL behind
|
||||
each show; the episodes themselves come from the publisher's own RSS, fetched by
|
||||
`GET /api/podcasts/show`.
|
||||
|
||||
**Spanish only, and checked rather than assumed.** A storefront says a podcast is sold in
|
||||
Spain or Mexico, which is not the same as being in Spanish — the Spanish comedy chart carries
|
||||
a Catalan show, the Argentine one an English show. So each show's feed is read (its first
|
||||
64 KB, with a `Range` request) and its `<language>` decides: `es`, `es-ES`, `es-419` and
|
||||
`spa` are kept, `ca` and `en` are dropped, and a feed that declares no language at all is
|
||||
kept too — genuinely Spanish feeds omit the tag, and dropping them over an omission would
|
||||
quietly remove good podcasts. `skipped` reports how many went each way, so a short list is
|
||||
never a mystery.
|
||||
|
||||
The audio never passes through this server: an episode is a file URL in the publisher's
|
||||
enclosure, handed to the phone. What this route costs is server-side requests to Apple and to
|
||||
each publisher's feed, so the answer is cached for thirty minutes.
|
||||
|
||||
A session is required. Not to protect the shows — they are public — but because this
|
||||
container sits on the owner's own network and fetches on behalf of whoever asks.
|
||||
parameters:
|
||||
- name: category
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
enum: [fitness, sports, comedy, news, history, truecrime, science, tech, society, business, fiction, education, music, leisure]
|
||||
description: Category key. Missing or unrecognised falls back to `fitness`.
|
||||
responses:
|
||||
'200':
|
||||
description: The categories for the chips, and the Spanish shows in the one asked for.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
ok: { type: boolean }
|
||||
categories:
|
||||
type: array
|
||||
description: Every chip the screen offers, so the client never hard-codes them.
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
key: { type: string }
|
||||
label: { type: string, description: Spanish label, like the rest of the show list. }
|
||||
category: { type: string, description: The category actually answered with. }
|
||||
label: { type: string }
|
||||
shows:
|
||||
type: array
|
||||
description: At most 20, Spanish-language only.
|
||||
items: { $ref: '#/components/schemas/PodcastShow' }
|
||||
skipped:
|
||||
type: object
|
||||
description: Why a candidate did not make the list — each reason counted.
|
||||
properties:
|
||||
duplicate: { type: integer, description: Listed by both storefronts. }
|
||||
language: { type: integer, description: Declared a language that is not Spanish. }
|
||||
unreadable: { type: integer, description: The feed did not answer. }
|
||||
failed: { type: integer, description: An unexpected error while checking (should be 0). }
|
||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||
|
||||
/api/podcasts/show:
|
||||
get:
|
||||
tags: [music]
|
||||
operationId: podcastsShow
|
||||
summary: One show's episodes, read out of the publisher's feed
|
||||
description: |
|
||||
The episode list behind a show, newest first, from the publisher's own RSS — the same feed
|
||||
every podcast app in the world reads. Each episode carries the `https://` URL of its audio
|
||||
file (`enclosure`), which is what the phone plays; nothing is downloaded by this server and
|
||||
no audio is proxied.
|
||||
|
||||
Two things are refused or reported rather than faked:
|
||||
|
||||
- **A URL this process will not fetch** is a `400`. Podcast feeds live on every host in the
|
||||
world, so there is no allowlist to hide behind: the rule is https, no credentials, a real
|
||||
hostname, and never a private address (no loopback, no `10.`/`192.168.`/`172.16-31.`, no
|
||||
link-local, no IPv6 literals, no `.local`). A redirect is checked the same way, because a
|
||||
redirect is otherwise the way around it.
|
||||
- **A feed that is not Spanish** is answered with `200` and `spanish: false` (with
|
||||
`episodes: []`), not with a hidden empty list: the show exists, it is simply not in
|
||||
Spanish, and saying which of the two it is is the whole point of the field.
|
||||
|
||||
Episodes without a public audio enclosure are left out: a trailer, a subscriber-only episode
|
||||
or a video is a row that plays silence or nothing. Feeds are up to a few megabytes, so the
|
||||
body is read with a cap and the connection is dropped at it; a feed cut off mid-item simply
|
||||
loses that last, unparseable item.
|
||||
parameters:
|
||||
- name: feed
|
||||
in: query
|
||||
required: true
|
||||
schema: { type: string }
|
||||
description: The show's feed URL, exactly as `GET /api/podcasts` returned it.
|
||||
- name: title
|
||||
in: query
|
||||
schema: { type: string, maxLength: 120 }
|
||||
description: The directory's name for the show, used only when the feed declares none.
|
||||
- name: image
|
||||
in: query
|
||||
schema: { type: string, maxLength: 300 }
|
||||
description: The directory's artwork, used only when the feed declares none.
|
||||
responses:
|
||||
'200':
|
||||
description: 'The show and its episodes — or `show: null` when the feed did not answer.'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
ok: { type: boolean }
|
||||
feed: { type: string }
|
||||
spanish: { type: boolean }
|
||||
show:
|
||||
allOf: [{ $ref: '#/components/schemas/PodcastShow' }]
|
||||
nullable: true
|
||||
description: Null when the feed could not be read at all.
|
||||
episodes:
|
||||
type: array
|
||||
description: At most 40, newest first. Empty when the show is not in Spanish.
|
||||
items: { $ref: '#/components/schemas/PodcastEpisode' }
|
||||
error: { type: string, nullable: true, description: '`unreadable` when `show` is null.' }
|
||||
'400':
|
||||
description: The feed URL is not one this server will fetch (not https, not a public host).
|
||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||
|
||||
/api/music/lookup:
|
||||
post:
|
||||
tags: [music]
|
||||
@@ -1808,6 +1939,56 @@ components:
|
||||
properties:
|
||||
ok: { type: boolean, const: true }
|
||||
|
||||
PodcastShow:
|
||||
type: object
|
||||
description: >-
|
||||
One show in the Podcasts section. `feed` is the only field the episodes can be fetched with,
|
||||
and it is what the show is saved by in a profile.
|
||||
required: [feed, name]
|
||||
properties:
|
||||
feed: { type: string, description: The publisher's RSS URL, https and public. }
|
||||
id: { type: string, description: The directory's own id for the show. }
|
||||
name: { type: string }
|
||||
author: { type: string }
|
||||
image: { type: string, nullable: true, description: HTTPS artwork. }
|
||||
genre: { type: string, nullable: true }
|
||||
country: { type: string, description: 'The storefront it was found in: `es` or `mx`.' }
|
||||
lang:
|
||||
type: string
|
||||
nullable: true
|
||||
description: >-
|
||||
What the feed itself declares — `es`, `es-ES`, `es-mx`… — or null when it declares
|
||||
nothing, which is a "kept, unconfirmed" and not a "not Spanish".
|
||||
example:
|
||||
feed: https://feeds.example.com/nadie-sabe-nada.rss
|
||||
name: Nadie Sabe Nada
|
||||
author: Cadena SER
|
||||
genre: Comedy
|
||||
country: es
|
||||
lang: es-ES
|
||||
|
||||
PodcastEpisode:
|
||||
type: object
|
||||
description: >-
|
||||
One episode: a file with a length, which is the difference that matters against a radio
|
||||
station — there is a position to remember and a place to resume from.
|
||||
required: [id, title, url]
|
||||
properties:
|
||||
id: { type: string, description: The feed's guid, or the audio URL when it has none. }
|
||||
title: { type: string }
|
||||
url: { type: string, description: The `https://` audio file to play. Never proxied. }
|
||||
date: { type: string, nullable: true, description: ISO 8601, from `pubDate`. }
|
||||
duration: { type: integer, nullable: true, description: Seconds, when the feed declares one. }
|
||||
image: { type: string, nullable: true, description: Episode artwork, else the show's. }
|
||||
episode: { type: integer, nullable: true, description: '`itunes:episode`, when the feed numbers them.' }
|
||||
bytes: { type: integer, nullable: true, description: The enclosure's declared size. }
|
||||
example:
|
||||
id: 312f2e94-ac78-5c37-8e0e-1f6c9d2a4b71
|
||||
title: Nadie Sabe Nada | 14x03 | En el corazón del ajo
|
||||
url: https://audio.example.com/nsn-14x03.mp3
|
||||
date: '2025-09-19T10:00:00.000Z'
|
||||
duration: 3135
|
||||
|
||||
RadioStation:
|
||||
type: object
|
||||
description: >-
|
||||
|
||||
Reference in new issue
Block a user