Fix:Ordering newly scanned in audio tracks properly #823

This commit is contained in:
advplyr 2022-07-12 15:02:08 -05:00
parent d11f9608b4
commit 2b91bff1af
2 changed files with 11 additions and 3 deletions

View File

@ -111,6 +111,10 @@ class AudioFile {
}
}
get isValidTrack() {
return !this.invalid && !this.exclude
}
// New scanner creates AudioFile from MediaFileScanner
setDataFromProbe(libraryFile, probeData) {
this.ino = libraryFile.ino || null

View File

@ -211,22 +211,26 @@ class MediaFileScanner {
Logger.debug(`Library Item "${scanData.path}" Audio file scan took ${mediaScanResult.elapsed}ms for ${mediaScanResult.audioFiles.length} with average time of ${mediaScanResult.averageScanDuration}ms`)
}
var totalAudioFilesToInclude = mediaScanResult.audioFiles.length
var newAudioFiles = mediaScanResult.audioFiles.filter(af => {
return !libraryItem.media.findFileWithInode(af.ino)
})
// Book: Adding audio files to book media
if (libraryItem.mediaType === 'book') {
var mediaScanFileInodes = mediaScanResult.audioFiles.map(af => af.ino)
// Filter for existing valid track audio files not included in the audio files scanned
var existingAudioFiles = libraryItem.media.audioFiles.filter(af => af.isValidTrack && !mediaScanFileInodes.includes(af.ino))
if (newAudioFiles.length) {
// Single Track Audiobooks
if (totalAudioFilesToInclude === 1) {
if (mediaScanFileInodes.length + existingAudioFiles.length === 1) {
var af = mediaScanResult.audioFiles[0]
af.index = 1
libraryItem.media.addAudioFile(af)
hasUpdated = true
} else {
this.runSmartTrackOrder(libraryItem, mediaScanResult.audioFiles)
var allAudioFiles = existingAudioFiles.concat(mediaScanResult.audioFiles)
this.runSmartTrackOrder(libraryItem, allAudioFiles)
hasUpdated = true
}
} else {