Episode scripts: file by season + episode so numbers can repeat per book; search labels for current series; v2.9.6
Publish Container / build (push) Successful in 16m51s
Publish Container / build (push) Successful in 16m51s
- Scripts keyed "<season>-<episode>" (legacy ones migrate on first start; unseasoned ones keep their plain key) - Season backfill handles episode numbers shared across seasons (title match fallback) - Fix: "Backfill seasons from RSS" was swallowed by the upload route - Global search labels script results with the title of the series playing now (both lanes), not just finished books Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ddedf0f81
commit
752611d121
7 files changed
+114
-41
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// Episode scripts are filed by season + episode number ("2-1"), because each book of the Bible
|
||||
// is its own podcast season and episode numbers can restart in every season. A script with no
|
||||
// season keeps its plain episode number as its key.
|
||||
|
||||
export function scriptKey(season, episodeNumber) {
|
||||
const ep = String(episodeNumber ?? '').trim()
|
||||
const s = String(season ?? '').trim()
|
||||
return /^\d+$/.test(s) ? `${s}-${ep}` : ep
|
||||
}
|
||||
|
||||
// The episode number a stored script belongs to (new entries record it; legacy ones are keyed by it).
|
||||
export function scriptEpisodeNumber(key, entry) {
|
||||
if (entry && typeof entry.episodeNumber === 'string' && entry.episodeNumber) return entry.episodeNumber
|
||||
const parts = String(key).split('-')
|
||||
return parts[parts.length - 1]
|
||||
}
|
||||
|
||||
// One-time move of legacy scripts ({ "7": { season: "1" } }) to season-episode keys ({ "1-7": ... }).
|
||||
// Scripts without a season stay under their plain episode number. Never overwrites an existing key.
|
||||
export function migrateScriptKeys(scripts) {
|
||||
const next = {}
|
||||
let changed = false
|
||||
for (const [key, entry] of Object.entries(scripts ?? {})) {
|
||||
if (!entry || typeof entry !== 'object') continue
|
||||
const episodeNumber = scriptEpisodeNumber(key, entry)
|
||||
const wanted = scriptKey(entry.season, episodeNumber)
|
||||
const targetKey = wanted !== key && !(wanted in scripts) && !(wanted in next) ? wanted : key
|
||||
const withEpisode = entry.episodeNumber === episodeNumber ? entry : { ...entry, episodeNumber }
|
||||
if (targetKey !== key || withEpisode !== entry) changed = true
|
||||
next[targetKey] = withEpisode
|
||||
}
|
||||
return { scripts: next, changed }
|
||||
}
|
||||
Reference in new issue
Block a user