From e7bd24bbaad582abd5f57762d9a9dc9ab608d574 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:43:34 -0400 Subject: [PATCH] Transcripts: a podcast episode gets its transcript going as soon as you play it (published, else made on your server) --- public/lyrics-view.js | 22 +++++++++++++++++++--- public/sw.js | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/public/lyrics-view.js b/public/lyrics-view.js index a0c4a37..c894955 100644 --- a/public/lyrics-view.js +++ b/public/lyrics-view.js @@ -43,12 +43,15 @@ async function lyrFromPlex(t) { // lyrics stored with the song (embedded, a .lrc /** A transcript: the show's own if it publishes one, else (on request) one made on this server. Polls while that is being made. */ async function lyrSpoken(t, start) { const q = new URLSearchParams({ key: t.key, src: t.src || '' }); - for (let n = 0; ; n++) { + for (let n = 0; ; n++) { // (n restarts at -1 after an automatic start, so the POST goes out once) if (!lyr.el || lyr.key !== t.key) return null; - let r; try { r = await jfetch('/api/transcript?' + q, start && n === 0 ? { method: 'POST' } : undefined); } catch (e) { return { found: false, error: e.message }; } + let r; try { r = await jfetch('/api/transcript?' + q, start && n <= 0 ? { method: 'POST' } : undefined); } catch (e) { return { found: false, error: e.message }; } if (r.state === 'ready') { r.transcript.spoken = true; return r.transcript; } if (r.state === 'error') return { found: false, error: r.error, canTranscribe: r.canTranscribe, none: true }; - if (r.state === 'none') return { found: false, none: true, canTranscribe: r.canTranscribe, why: r.why }; + if (r.state === 'none') { + if (r.canTranscribe && !start && String(t.key).startsWith('pod:') && !lyrPref().noAuto) { start = true; n = -1; continue; } // nothing published: make one (an episode, not a whole book) + return { found: false, none: true, canTranscribe: r.canTranscribe, why: r.why }; + } const body = lyr.el.querySelector('#lyrbody'); if (body) body.innerHTML = `
Making a transcript on your server… ${Math.max(0, Math.round((Date.now() - r.since) / 60000))} min so far.
You can close this: it keeps going, and it is kept for next time.