add srt files
This commit is contained in:
@@ -31,6 +31,8 @@ async function podcastData (data) {
|
||||
var file_stem
|
||||
if (data.season === 1) {
|
||||
file_stem = `ep${data.episode}`
|
||||
} if (data.season === 2) {
|
||||
file_stem = `${seasonEpisodeFormat(null, {...data, episodePrefix: "ep"}).toLowerCase()}`
|
||||
} else {
|
||||
file_stem = `${seasonEpisodeFormat(null, data).toLowerCase()}`
|
||||
}
|
||||
@@ -50,7 +52,18 @@ async function podcastData (data) {
|
||||
}
|
||||
}).catch((e)=>{return null})
|
||||
|
||||
const transcript_exists_promise = new Promise ((resolve, reject) => {
|
||||
const transcript_page_exists_promises = [
|
||||
`${data.page.filePathStem}`,
|
||||
`../../../transcripts/${file_stem}`
|
||||
].filter(file_path=>file_path).map((file_path)=>
|
||||
fs.access(path.resolve(data.page.inputPath, `${file_path}.srt`))
|
||||
.then(()=>path.resolve(data.page.filePathStem, file_path))
|
||||
.catch((e)=>{
|
||||
return null
|
||||
})
|
||||
)
|
||||
|
||||
transcript_file_exists_promise = new Promise ((resolve, reject) => {
|
||||
if (data.podcast.transcriptUrl) {
|
||||
resolve(data.podcast.transcriptUrl)
|
||||
} else {
|
||||
@@ -68,7 +81,8 @@ async function podcastData (data) {
|
||||
|
||||
const result = {
|
||||
"enclosureUrl": await mp3_exists_promise,
|
||||
"transcriptUrl": await transcript_exists_promise,
|
||||
"transcriptUrl": await transcript_file_exists_promise,
|
||||
"transcriptPage": (await Promise.all(transcript_page_exists_promises)).find(i=>i),
|
||||
"title": data.podcast.title || `${seasonEpisodeFormat(null, data)}: ${data.title || "Episode " + data.episode}`,
|
||||
"image" : data.podcast.image || data.image
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user