mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-02 01:16:54 +02:00
Update:Trim whitespace from audio file meta tag values #1305
This commit is contained in:
parent
c4be75b5bd
commit
657d4dd705
@ -295,16 +295,21 @@ class BookMetadata {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
var updatePayload = {}
|
const updatePayload = {}
|
||||||
|
|
||||||
// Metadata is only mapped to the book if it is empty
|
// Metadata is only mapped to the book if it is empty
|
||||||
MetadataMapArray.forEach((mapping) => {
|
MetadataMapArray.forEach((mapping) => {
|
||||||
var value = audioFileMetaTags[mapping.tag]
|
let value = audioFileMetaTags[mapping.tag]
|
||||||
var tagToUse = mapping.tag
|
// let tagToUse = mapping.tag
|
||||||
if (!value && mapping.altTag) {
|
if (!value && mapping.altTag) {
|
||||||
value = audioFileMetaTags[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 (value) {
|
||||||
if (mapping.key === 'narrators' && (!this.narrators.length || overrideExistingDetails)) {
|
if (mapping.key === 'narrators' && (!this.narrators.length || overrideExistingDetails)) {
|
||||||
updatePayload.narrators = this.parseNarratorsTag(value)
|
updatePayload.narrators = this.parseNarratorsTag(value)
|
||||||
@ -313,7 +318,7 @@ class BookMetadata {
|
|||||||
} else if (mapping.key === 'genres' && (!this.genres.length || overrideExistingDetails)) {
|
} else if (mapping.key === 'genres' && (!this.genres.length || overrideExistingDetails)) {
|
||||||
updatePayload.genres = this.parseGenresTag(value)
|
updatePayload.genres = this.parseGenresTag(value)
|
||||||
} else if (mapping.key === 'series' && (!this.series.length || overrideExistingDetails)) {
|
} 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)
|
updatePayload.series = this.parseSeriesTag(value, sequenceTag)
|
||||||
} else if (!this[mapping.key] || overrideExistingDetails) {
|
} else if (!this[mapping.key] || overrideExistingDetails) {
|
||||||
updatePayload[mapping.key] = value
|
updatePayload[mapping.key] = value
|
||||||
|
@ -88,8 +88,8 @@ class PodcastMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchQuery(query) { // Returns key if match is found
|
searchQuery(query) { // Returns key if match is found
|
||||||
var keysToCheck = ['title', 'author', 'itunesId', 'itunesArtistId']
|
const keysToCheck = ['title', 'author', 'itunesId', 'itunesArtistId']
|
||||||
for (var key of keysToCheck) {
|
for (const key of keysToCheck) {
|
||||||
if (this[key] && cleanStringForSearch(String(this[key])).includes(query)) {
|
if (this[key] && cleanStringForSearch(String(this[key])).includes(query)) {
|
||||||
return {
|
return {
|
||||||
matchKey: key,
|
matchKey: key,
|
||||||
@ -118,8 +118,8 @@ class PodcastMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
var json = this.toJSON()
|
const json = this.toJSON()
|
||||||
var hasUpdates = false
|
let hasUpdates = false
|
||||||
for (const key in json) {
|
for (const key in json) {
|
||||||
if (payload[key] !== undefined) {
|
if (payload[key] !== undefined) {
|
||||||
if (!areEquivalent(payload[key], json[key])) {
|
if (!areEquivalent(payload[key], json[key])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user