mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-15 16:01:30 +00:00
Early out if the description doesn't contain and timestamps
This commit is contained in:
parent
8710816a6f
commit
7f88d4b036
3 changed files with 24 additions and 3 deletions
|
|
@ -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')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue