Update:Trim whitespace from audio file meta tag values #1305

This commit is contained in:
advplyr 2022-12-21 07:13:28 -06:00
parent c4be75b5bd
commit 657d4dd705
2 changed files with 14 additions and 9 deletions

View File

@ -295,16 +295,21 @@ class BookMetadata {
}
]
var updatePayload = {}
const updatePayload = {}
// Metadata is only mapped to the book if it is empty
MetadataMapArray.forEach((mapping) => {
var value = audioFileMetaTags[mapping.tag]
var tagToUse = mapping.tag
let value = audioFileMetaTags[mapping.tag]
// let tagToUse = mapping.tag
if (!value && mapping.altTag) {
value = audioFileMetaTags[mapping.altTag]
tagToUse = mapping.altTag
// tagToUse = mapping.altTag
}
if (value && typeof value === 'string') { // Trim whitespace
value = value.trim()
}
if (value) {
if (mapping.key === 'narrators' && (!this.narrators.length || overrideExistingDetails)) {
updatePayload.narrators = this.parseNarratorsTag(value)
@ -313,7 +318,7 @@ class BookMetadata {
} else if (mapping.key === 'genres' && (!this.genres.length || overrideExistingDetails)) {
updatePayload.genres = this.parseGenresTag(value)
} else if (mapping.key === 'series' && (!this.series.length || overrideExistingDetails)) {
var sequenceTag = audioFileMetaTags.tagSeriesPart || null
const sequenceTag = audioFileMetaTags.tagSeriesPart || null
updatePayload.series = this.parseSeriesTag(value, sequenceTag)
} else if (!this[mapping.key] || overrideExistingDetails) {
updatePayload[mapping.key] = value

View File

@ -88,8 +88,8 @@ class PodcastMetadata {
}
searchQuery(query) { // Returns key if match is found
var keysToCheck = ['title', 'author', 'itunesId', 'itunesArtistId']
for (var key of keysToCheck) {
const keysToCheck = ['title', 'author', 'itunesId', 'itunesArtistId']
for (const key of keysToCheck) {
if (this[key] && cleanStringForSearch(String(this[key])).includes(query)) {
return {
matchKey: key,
@ -118,8 +118,8 @@ class PodcastMetadata {
}
update(payload) {
var json = this.toJSON()
var hasUpdates = false
const json = this.toJSON()
let hasUpdates = false
for (const key in json) {
if (payload[key] !== undefined) {
if (!areEquivalent(payload[key], json[key])) {