Early out if the description doesn't contain and timestamps

This commit is contained in:
Harry Rose 2026-03-17 19:43:09 +00:00
parent 8710816a6f
commit 7f88d4b036
3 changed files with 24 additions and 3 deletions

View file

@ -36,6 +36,12 @@ module.exports.parse = (podcastDescription, audioDurationSecs) => {
// Split on "</p>", "<br />", "\n", </li>
const descriptionLineSplitRegex = /\<\s*\/\s*p\s*\>|\<\s*br\s*\/\>|\n|\<\s*\/\s*li\s*\>/
// Early out if there aren't any timestamps in the entire description
if (timestampRegex.exec(podcastDescription) == null) {
Logger.debug('No timestamps found in description, bailing out early')
return []
}
var descriptionLines = podcastDescription.split(descriptionLineSplitRegex)
var newChapters = []
@ -98,8 +104,6 @@ module.exports.parse = (podcastDescription, audioDurationSecs) => {
newChapters[newChapters.length - 1].end = audioDurationSecs
}
Logger.info(`Successfully generated ${newChapters.length} chapters`)
if (newChapters.length == 1) {
throw new Error('Only one chapter found, treating as invalid description')
}