mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Add:Alternative ID3 tags
This commit is contained in:
parent
60654ae45d
commit
4be004290d
@ -296,7 +296,6 @@ class AudioFile {
|
|||||||
if (!this.metadata || !this.metadata.isEqual(scannedAudioFile.metadata)) {
|
if (!this.metadata || !this.metadata.isEqual(scannedAudioFile.metadata)) {
|
||||||
this.metadata = scannedAudioFile.metadata
|
this.metadata = scannedAudioFile.metadata
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
// console.log('metadata updated for audio file')
|
|
||||||
}
|
}
|
||||||
} else if (key === 'chapters') {
|
} else if (key === 'chapters') {
|
||||||
if (this.syncChapters(newjson.chapters || [])) {
|
if (this.syncChapters(newjson.chapters || [])) {
|
||||||
|
@ -322,10 +322,12 @@ class Book {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: 'tagAlbum',
|
tag: 'tagAlbum',
|
||||||
|
altTag: 'tagTitle',
|
||||||
key: 'title',
|
key: 'title',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: 'tagArtist',
|
tag: 'tagArtist',
|
||||||
|
altTag: 'tagAlbumArtist',
|
||||||
key: 'author'
|
key: 'author'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -343,16 +345,23 @@ class Book {
|
|||||||
]
|
]
|
||||||
|
|
||||||
var updatePayload = {}
|
var 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) => {
|
||||||
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
|
// Genres can contain multiple
|
||||||
if (mapping.key === 'genres' && (!this[mapping.key].length || !this[mapping.key] || overrideExistingDetails)) {
|
if (mapping.key === 'genres' && (!this[mapping.key].length || !this[mapping.key] || overrideExistingDetails)) {
|
||||||
updatePayload[mapping.key] = this.parseGenresTag(audioFileMetadata[mapping.tag])
|
updatePayload[mapping.key] = this.parseGenresTag(audioFileMetadata[tagToUse])
|
||||||
// Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key].join(',')}`)
|
// Logger.debug(`[Book] Mapping metadata to key ${tagToUse} => ${mapping.key}: ${updatePayload[mapping.key].join(',')}`)
|
||||||
} else if (!this[mapping.key] || overrideExistingDetails) {
|
} else if (!this[mapping.key] || overrideExistingDetails) {
|
||||||
updatePayload[mapping.key] = audioFileMetadata[mapping.tag]
|
updatePayload[mapping.key] = audioFileMetadata[tagToUse]
|
||||||
// Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key]}`)
|
// Logger.debug(`[Book] Mapping metadata to key ${tagToUse} => ${mapping.key}: ${updatePayload[mapping.key]}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -153,7 +153,7 @@ function parseTags(format, verbose) {
|
|||||||
file_tag_track: tryGrabTags(format, 'track', 'trck', 'trk'),
|
file_tag_track: tryGrabTags(format, 'track', 'trck', 'trk'),
|
||||||
file_tag_album: tryGrabTags(format, 'album', 'talb', 'tal'),
|
file_tag_album: tryGrabTags(format, 'album', 'talb', 'tal'),
|
||||||
file_tag_artist: tryGrabTags(format, 'artist', 'tpe1', 'tp1'),
|
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_date: tryGrabTags(format, 'date', 'tyer', 'tye'),
|
||||||
file_tag_composer: tryGrabTags(format, 'composer', 'tcom', 'tcm'),
|
file_tag_composer: tryGrabTags(format, 'composer', 'tcom', 'tcm'),
|
||||||
file_tag_publisher: tryGrabTags(format, 'publisher', 'tpub', 'tpb'),
|
file_tag_publisher: tryGrabTags(format, 'publisher', 'tpub', 'tpb'),
|
||||||
|
Loading…
Reference in New Issue
Block a user