implement some feautres in transcript search

This commit is contained in:
2024-12-26 13:37:33 -06:00
parent f705cca038
commit 0dcb7634ae
8 changed files with 101 additions and 30 deletions

View File

@@ -8,23 +8,20 @@ class SearchIndex {
}
async render (data) {
const episodesWithTranscript = data.collections.episode.filter(e=>e.data.podcast?.transcriptUrl)
const promises = episodesWithTranscript.map((episode)=>{
const {transcriptUrl} = episode.data.podcast
return Fetch(transcriptUrl, {type:'text', duration: "1d"})
.then(srt_buffer=>parseText(srt_buffer.toString(), {type:'srt'}))
.then(({cues})=>cues)
.then((cues)=>({
name: path.basename(transcriptUrl,".srt"),
const episodesWithTranscript = data.collections.episode.filter(e=>e.data.podcast?.transcriptPage)
const result = episodesWithTranscript.map((episode)=>{
const transcriptPage = data.collections.transcript.find(t=>t.data.episode==episode.data.episode && t.data.season == episode.data.season)
if (!transcriptPage) {return null}
return {
transcriptPageUrl: this.url(transcriptPage.url),
episode: episode.data.episode,
season: episode.data.season,
title: episode.data.title,
url: `${this.url(episode.url)}`,
cues: cues.map(({id, startTime, text})=>({id,startTime,text}))
}))
segments: transcriptPage.data.segments
}
})
const result = await Promise.all(promises)
return JSON.stringify(result)
return JSON.stringify(result.filter(r=>r))
}
}