Cleaned function getSubtitle

This commit is contained in:
Cassie Esposito 2022-05-19 22:31:55 -07:00
parent dd664da871
commit 13d21e90f8

View File

@ -220,7 +220,7 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) {
var [title, narrators] = getNarrator(title) var [title, narrators] = getNarrator(title)
if (series) { var [series, title, sequence] = getSeries(series, title) } if (series) { var [series, title, sequence] = getSeries(series, title) }
var [title, publishedYear] = getPublishedYear(title) var [title, publishedYear] = getPublishedYear(title)
if (parseSubtitle) { var [title, subtitle] = getSubtitle(title) } if (parseSubtitle) { var [title, subtitle] = getSubtitle(title) } // Subtitle can be parsed from the title if user enabled
return { return {
mediaMetadata: { mediaMetadata: {
@ -286,15 +286,9 @@ function getSeries(series, title) {
} }
function getSubtitle(title) { function getSubtitle(title) {
// Subtitle can be parsed from the title if user enabled
// Subtitle is everything after " - " // Subtitle is everything after " - "
var subtitle = null var splitTitle = title.split(' - ')
if (title.includes(' - ')) { return [splitTitle.shift(), splitTitle.join(' - ')]
var splitOnSubtitle = title.split(' - ')
title = splitOnSubtitle.shift()
subtitle = splitOnSubtitle.join(' - ')
}
return [title, subtitle]
} }
function getPublishedYear(title) { function getPublishedYear(title) {