Add:Alternative ID3 tags

This commit is contained in:
advplyr 2021-11-25 19:23:22 -06:00
parent 60654ae45d
commit 4be004290d
3 changed files with 15 additions and 7 deletions

View File

@ -296,7 +296,6 @@ class AudioFile {
if (!this.metadata || !this.metadata.isEqual(scannedAudioFile.metadata)) {
this.metadata = scannedAudioFile.metadata
hasUpdated = true
// console.log('metadata updated for audio file')
}
} else if (key === 'chapters') {
if (this.syncChapters(newjson.chapters || [])) {

View File

@ -322,10 +322,12 @@ class Book {
},
{
tag: 'tagAlbum',
altTag: 'tagTitle',
key: 'title',
},
{
tag: 'tagArtist',
altTag: 'tagAlbumArtist',
key: 'author'
},
{
@ -343,16 +345,23 @@ class Book {
]
var updatePayload = {}
// Metadata is only mapped to the book if it is empty
MetadataMapArray.forEach((mapping) => {
if (audioFileMetadata[mapping.tag]) {
var value = audioFileMetadata[mapping.tag]
var tagToUse = mapping.tag
if (!value && mapping.altTag) {
value = audioFileMetadata[mapping.altTag]
tagToUse = mapping.altTag
}
if (value) {
// Genres can contain multiple
if (mapping.key === 'genres' && (!this[mapping.key].length || !this[mapping.key] || overrideExistingDetails)) {
updatePayload[mapping.key] = this.parseGenresTag(audioFileMetadata[mapping.tag])
// Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key].join(',')}`)
updatePayload[mapping.key] = this.parseGenresTag(audioFileMetadata[tagToUse])
// Logger.debug(`[Book] Mapping metadata to key ${tagToUse} => ${mapping.key}: ${updatePayload[mapping.key].join(',')}`)
} else if (!this[mapping.key] || overrideExistingDetails) {
updatePayload[mapping.key] = audioFileMetadata[mapping.tag]
// Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key]}`)
updatePayload[mapping.key] = audioFileMetadata[tagToUse]
// Logger.debug(`[Book] Mapping metadata to key ${tagToUse} => ${mapping.key}: ${updatePayload[mapping.key]}`)
}
}
})

View File

@ -153,7 +153,7 @@ function parseTags(format, verbose) {
file_tag_track: tryGrabTags(format, 'track', 'trck', 'trk'),
file_tag_album: tryGrabTags(format, 'album', 'talb', 'tal'),
file_tag_artist: tryGrabTags(format, 'artist', 'tpe1', 'tp1'),
file_tag_albumartist: tryGrabTags(format, 'albumartist', 'tpe2'),
file_tag_albumartist: tryGrabTags(format, 'albumartist', 'album_artist', 'tpe2'),
file_tag_date: tryGrabTags(format, 'date', 'tyer', 'tye'),
file_tag_composer: tryGrabTags(format, 'composer', 'tcom', 'tcm'),
file_tag_publisher: tryGrabTags(format, 'publisher', 'tpub', 'tpb'),