mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-02 01:16:54 +02:00
Fix:Ordering newly scanned in audio tracks properly #823
This commit is contained in:
parent
d11f9608b4
commit
2b91bff1af
@ -111,6 +111,10 @@ class AudioFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isValidTrack() {
|
||||||
|
return !this.invalid && !this.exclude
|
||||||
|
}
|
||||||
|
|
||||||
// New scanner creates AudioFile from MediaFileScanner
|
// New scanner creates AudioFile from MediaFileScanner
|
||||||
setDataFromProbe(libraryFile, probeData) {
|
setDataFromProbe(libraryFile, probeData) {
|
||||||
this.ino = libraryFile.ino || null
|
this.ino = libraryFile.ino || null
|
||||||
|
@ -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`)
|
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 => {
|
var newAudioFiles = mediaScanResult.audioFiles.filter(af => {
|
||||||
return !libraryItem.media.findFileWithInode(af.ino)
|
return !libraryItem.media.findFileWithInode(af.ino)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Book: Adding audio files to book media
|
// Book: Adding audio files to book media
|
||||||
if (libraryItem.mediaType === 'book') {
|
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) {
|
if (newAudioFiles.length) {
|
||||||
// Single Track Audiobooks
|
// Single Track Audiobooks
|
||||||
if (totalAudioFilesToInclude === 1) {
|
if (mediaScanFileInodes.length + existingAudioFiles.length === 1) {
|
||||||
var af = mediaScanResult.audioFiles[0]
|
var af = mediaScanResult.audioFiles[0]
|
||||||
af.index = 1
|
af.index = 1
|
||||||
libraryItem.media.addAudioFile(af)
|
libraryItem.media.addAudioFile(af)
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
} else {
|
} else {
|
||||||
this.runSmartTrackOrder(libraryItem, mediaScanResult.audioFiles)
|
var allAudioFiles = existingAudioFiles.concat(mediaScanResult.audioFiles)
|
||||||
|
this.runSmartTrackOrder(libraryItem, allAudioFiles)
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user