Files
kuentagym/docs/PODCASTS.md
T
dsantillan d5cf0d8d64
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 se ordena: pestañas, buscador, y listas de diez con "Mostrar más"
La pantalla era una sola columna —radio, después podcasts, después listas— y tres
listas de veinte filas es una pantalla por la que se baja buscando lo que ya sabías
que querías. Ahora pregunta primero: **Radio | Podcasts | Listas**, una lista a la
vez, **diez filas** y un **"Mostrar más"** que dice cuántas esconde. Nada queda fuera
de alcance y nada más está en pantalla mientras decidís: el subtítulo también dice qué
estás mirando en vez de hablar siempre de listas.

El **buscador** busca lo que tengas abierto y en el origen, no en la página: `jazz`
le pregunta al directorio de emisoras y `crimen` al de podcasts de Apple —filtrado,
como siempre, a español, y pasando por **la misma** función de filtro que una
categoría, porque un segundo camino más barato al catálogo es como se pierde una
regla—. Con menos de dos letras no se busca ni se pide nada: una letra coincide con
todo y sería una petición por tecla para una respuesta inservible.

La búsqueda de emisoras **ordena por lo que se buscó**: el directorio coincide con
subcadenas en cualquier parte, así que *techno* devolvía "# TOP 100 CLUB CHARTS -
DANCE & DJ MIX RADIO" —real, con "techno" entre sus etiquetas— por delante de toda
emisora llamada Techno Algo. El nombre pesa antes que la popularidad y a igual peso
gana el nombre más corto; los canales de SomaFM y los mixes de Paradise que coinciden
van primero, porque no tienen publicidad y su stream ya se sabe que funciona. La
búsqueda del directorio va con `is_https=true`, cacheada por consulta.

`lib/paging.js` es puro y tiene test porque tiene un borde fácil de equivocar en un
componente: una lista que se encoge —una búsqueda nueva, una emisora desmarcada— no
puede dejar el tamaño de página pasado del final, que se ve como "Mostrar más" que no
hace nada.

Verificado contra los directorios reales: `radio?q=jazz` → Sonic Universe (SomaFM) y
después Jazz 24; `radio?q=miami` → Miami Beach Radio, 105 Miami; `podcasts?q=crimen`
→ 20 programas en español (es, es-ar) y `q=entrenamiento en casa` → 3; `?q=j` no
busca. `relevance` y `rankStations` se comprobaron por mutación: sacar el orden hace
fallar el test que lo mira de punta a punta.
2026-09-23 21:24:50 -04:00

6.8 KiB

Podcasts

Radio, but the other half of it: episodes, in Spanish, that you can resume.

Open Música → Podcasts (the middle tab; the screen shows one list at a time, ten shows with a "show more"), search by name if you know what you are looking for, or pick a category (Salud y fitness, Deporte, Comedia, Noticias, Historia, Crímenes reales, Ciencia, Tecnología, Sociedad y cultura, Negocios, Ficción, Educación, Música, Ocio), tap a show, tap an episode. It plays across screens, keeps going with the screen locked, and comes back where you left it.

Why podcasts and not just more radio

They are opposites in every way that matters to the player, and the difference is not cosmetic:

Radio A podcast
Source a live stream a file with a beginning and an end
Position meaningless the feature
Pause pause the stream pause, resume, seek ±, remember
Playing next the station's job yours: next episode
Length unknown, forever minutes, and worth showing

A podcast you cannot scrub is a podcast you do not use, which is why the player bar grows a progress hairline and two seek buttons when an episode is playing, and none of that exists for a station.

A search is not a weaker way in

Typing in the box above the tabs asks Apple's podcast search, both storefronts, and the results go through the same feed check and the same Spanish filter as a category's chart entries — one function on the server, used by both, so "Spanish only" cannot quietly stop applying to a search. That is the shape worth keeping: a second, cheaper path into a catalogue is how a rule like this gets lost.

Spanish only — checked, not assumed

The user asked for Spanish, so the app checks, and this is the part worth knowing before trusting a short list:

  • Apple's directory is browsed per storefront (es and mx). A storefront says where a podcast is sold, which is not the same as the language it is in: the Spanish comedy chart carries a Catalan show, and the Argentine one carries an English show.
  • So every show's feed is read — its first 64 KB, with a Range request, because <language> is channel metadata that sits in the first ~1.5 KB and always before the first <item> — and its <language> decides. es, es-ES, es-419 and spa stay; ca, en, pt and the rest go.
  • A feed with no tag at all stays. Some genuinely Spanish feeds omit it (La Ruina does), and dropping them over an omission would quietly remove good podcasts; the storefront is the fallback signal, and it is not a guess.
  • The response says how many shows were dropped and why (skipped: { duplicate, language, unreadable, failed }), so a list of fifteen is never a mystery.
  • Opening a show re-checks against the whole feed, and a show in another language is answered with spanish: false and a sentence — not with an empty episode list that looks like a feed with nothing in it.

Nothing is proxied, and nothing is downloaded

An episode arrives as an https:// URL from the publisher's own enclosure, the phone plays it, and the bytes go from the publisher to the phone. This server contributes the list, exactly the bargain the radio makes — no audio through the container, no copies, no downloads, no disk.

What this does cost, server-side, is requests: Apple's charts and lookup (two per category), one 64 KB Range request per show to read its language, and one fetch per feed when a show is opened (up to ~6 MB for a big archive — cached for half an hour, parsed, and the parsed episodes are what is kept, never the body, because forty episodes are a few kilobytes and a feed is megabytes).

What may be fetched

Radio has a host allowlist because it talks to three services. Podcasts cannot: feeds live on every host in the world. So this is the other rule, and it is the rule that matters for an api container sitting inside somebody's house:

  • https only, no credentials in the URL, a real hostname and never a private address — no loopback, no 10./192.168./172.16-31., no carrier-grade NAT, no link-local (the 169.254.169.254 metadata address is the classic target), no IPv6 literals, no .local or .internal.
  • The URL is checked and so is where the request ended up, because a redirect is otherwise the way around it.
  • Bodies are read with a cap and the connection is dropped the moment it is reached.
  • Both routes need a session — not to protect public podcasts, but because this process fetches on behalf of whoever asks.

The player, and the two things that are easy to get wrong

  • Audio only starts inside the tap. iOS allows audio to begin from a user gesture and from nothing else, so nothing asynchronous may sit between the finger and the play(): the episode URL is already in hand, and the store's playEpisode calls straight through.
  • The <audio> element lives outside React (frontend/src/lib/player.js), shared with the radio, so changing screens does not stop it and two kinds of media can never play at once.

Positions are saved to your profile — per episode, throttled to once every few seconds, and always on pause, on stop, when an episode ends and when the app goes to the background. That last one matters: iOS suspends a locked page's timers, so a position saved only from a tick would lose whatever was played with the screen off.

Episodes count as heard when they are within twenty seconds of the end, and starting one of those begins it again rather than resuming into its last seconds. Two hundred positions are kept per profile, newest first.

The screen locked, and the native shells

Safari and the installed PWA keep playing with the phone locked, and Media Session puts the episode, the show and the progress bar on the lock screen, with the controls reaching the same audio element. The two shell builds need configuration for that (see MOBILE.md) — in the PWA, nothing.

What this deliberately is not

  • Not a downloads app. There is no offline mode and no stored audio: the episode plays from the publisher every time, which is also why nothing here will ever be a copyright question.
  • Not Apple Podcasts' API. There is no such thing for third parties; the directory and the feeds are public, and that is what this uses — no key, no account, no Apple ID.
  • Not a proxy or a transcriber. No audio through the server, no speed-up, no ad-skipping.
  • Not a general podcast directory. Spanish is a filter, not a preference to be toggled.

Credits

  • Apple Podcasts directory — the charts and lookup used to find shows and their feeds. Public, keyless endpoints; the shows and episodes are the publishers' own.
  • The shows themselves belong to the people who make them; the audio is served from their hosts.