mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-03 01:35:08 +02:00
Fix: Scanner check path and inode value for removed books, scanner v5 outlined
This commit is contained in:
parent
ea366c00ca
commit
3fa0fe4b64
12 changed files with 553 additions and 7 deletions
74
server/scanner/AudioProbeData.js
Normal file
74
server/scanner/AudioProbeData.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
const AudioFileMetadata = require('../objects/AudioFileMetadata')
|
||||
|
||||
class AudioProbeData {
|
||||
constructor() {
|
||||
this.embeddedCoverArt = null
|
||||
this.format = null
|
||||
this.duration = null
|
||||
this.size = null
|
||||
this.bitRate = null
|
||||
this.codec = null
|
||||
this.timeBase = null
|
||||
this.language = null
|
||||
this.channelLayout = null
|
||||
this.channels = null
|
||||
this.sampleRate = null
|
||||
this.chapters = []
|
||||
|
||||
this.audioFileMetadata = null
|
||||
|
||||
this.trackNumber = null
|
||||
this.trackTotal = null
|
||||
}
|
||||
|
||||
getDefaultAudioStream(audioStreams) {
|
||||
if (audioStreams.length === 1) return audioStreams[0]
|
||||
var defaultStream = audioStreams.find(a => a.is_default)
|
||||
if (!defaultStream) return audioStreams[0]
|
||||
return defaultStream
|
||||
}
|
||||
|
||||
getEmbeddedCoverArt(videoStream) {
|
||||
const ImageCodecs = ['mjpeg', 'jpeg', 'png']
|
||||
return ImageCodecs.includes(videoStream.codec) ? videoStream.codec : null
|
||||
}
|
||||
|
||||
setData(data) {
|
||||
var audioStream = getDefaultAudioStream(data.audio_streams)
|
||||
|
||||
this.embeddedCoverArt = data.video_stream ? this.getEmbeddedCoverArt(data.video_stream) : false
|
||||
this.format = data.format
|
||||
this.duration = data.duration
|
||||
this.size = data.size
|
||||
this.bitRate = audioStream.bit_rate || data.bit_rate
|
||||
this.codec = audioStream.codec
|
||||
this.timeBase = audioStream.time_base
|
||||
this.language = audioStream.language
|
||||
this.channelLayout = audioStream.channel_layout
|
||||
this.channels = audioStream.channels
|
||||
this.sampleRate = audioStream.sample_rate
|
||||
this.chapters = data.chapters || []
|
||||
|
||||
var metatags = {}
|
||||
for (const key in data) {
|
||||
if (data[key] && key.startsWith('file_tag')) {
|
||||
metatags[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
this.audioFileMetadata = new AudioFileMetadata()
|
||||
this.audioFileMetadata.setData(metatags)
|
||||
|
||||
// Track ID3 tag might be "3/10" or just "3"
|
||||
if (this.audioFileMetadata.tagTrack) {
|
||||
var trackParts = this.audioFileMetadata.tagTrack.split('/').map(part => Number(part))
|
||||
if (trackParts.length > 0) {
|
||||
this.trackNumber = trackParts[0]
|
||||
}
|
||||
if (trackParts.length > 1) {
|
||||
this.trackTotal = trackParts[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = AudioProbeData
|
Loading…
Add table
Add a link
Reference in a new issue