mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-12 18:35:00 +02:00
Update scanner, music meta tags and fix issue with force update
This commit is contained in:
parent
5410aae8fc
commit
9de7be1cb4
11 changed files with 388 additions and 110 deletions
|
@ -1,4 +1,4 @@
|
|||
const AudioFileMetadata = require('../objects/metadata/AudioMetaTags')
|
||||
const AudioMetaTags = require('../objects/metadata/AudioMetaTags')
|
||||
|
||||
class MediaProbeData {
|
||||
constructor(probeData) {
|
||||
|
@ -19,7 +19,7 @@ class MediaProbeData {
|
|||
this.sampleRate = null
|
||||
this.chapters = []
|
||||
|
||||
this.audioFileMetadata = null
|
||||
this.audioMetaTags = null
|
||||
|
||||
this.trackNumber = null
|
||||
this.trackTotal = null
|
||||
|
@ -34,8 +34,8 @@ class MediaProbeData {
|
|||
|
||||
construct(probeData) {
|
||||
for (const key in probeData) {
|
||||
if (key === 'audioFileMetadata' && probeData[key]) {
|
||||
this[key] = new AudioFileMetadata(probeData[key])
|
||||
if (key === 'audioMetaTags' && probeData[key]) {
|
||||
this[key] = new AudioMetaTags(probeData[key])
|
||||
} else if (this[key] !== undefined) {
|
||||
this[key] = probeData[key]
|
||||
}
|
||||
|
@ -48,61 +48,35 @@ class MediaProbeData {
|
|||
}
|
||||
|
||||
setData(data) {
|
||||
var audioStream = data.audio_stream
|
||||
this.embeddedCoverArt = data.video_stream ? this.getEmbeddedCoverArt(data.video_stream) : null
|
||||
this.format = data.format
|
||||
this.duration = data.duration
|
||||
this.size = data.size
|
||||
|
||||
this.audioStream = audioStream
|
||||
this.audioStream = data.audio_stream
|
||||
this.videoStream = this.embeddedCoverArt ? null : data.video_stream || null
|
||||
|
||||
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.bitRate = this.audioStream.bit_rate || data.bit_rate
|
||||
this.codec = this.audioStream.codec
|
||||
this.timeBase = this.audioStream.time_base
|
||||
this.language = this.audioStream.language
|
||||
this.channelLayout = this.audioStream.channel_layout
|
||||
this.channels = this.audioStream.channels
|
||||
this.sampleRate = this.audioStream.sample_rate
|
||||
this.chapters = data.chapters || []
|
||||
|
||||
if (data.tags) { // New for tone library data (toneProber.js)
|
||||
this.audioFileMetadata = new AudioFileMetadata()
|
||||
this.audioFileMetadata.setDataFromTone(data.tags)
|
||||
} else { // Data from ffprobe (prober.js)
|
||||
var metatags = {}
|
||||
for (const key in data) {
|
||||
if (data[key] && key.startsWith('file_tag')) {
|
||||
metatags[key] = data[key]
|
||||
}
|
||||
}
|
||||
this.audioMetaTags = new AudioMetaTags()
|
||||
this.audioMetaTags.setData(data.tags)
|
||||
}
|
||||
|
||||
this.audioFileMetadata = new AudioFileMetadata()
|
||||
this.audioFileMetadata.setData(metatags)
|
||||
}
|
||||
setDataFromTone(data) {
|
||||
// TODO: Implement
|
||||
|
||||
// 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) {
|
||||
// Fractional track numbers not supported
|
||||
this.trackNumber = !isNaN(trackParts[0]) ? Math.trunc(trackParts[0]) : null
|
||||
}
|
||||
if (trackParts.length > 1) {
|
||||
this.trackTotal = !isNaN(trackParts[1]) ? trackParts[1] : null
|
||||
}
|
||||
}
|
||||
|
||||
// Parse disc tag
|
||||
if (this.audioFileMetadata.tagDisc) {
|
||||
var discParts = this.audioFileMetadata.tagDisc.split('/').map(p => Number(p))
|
||||
if (discParts.length > 0) {
|
||||
this.discNumber = !isNaN(discParts[0]) ? Math.trunc(discParts[0]) : null
|
||||
}
|
||||
if (discParts.length > 1) {
|
||||
this.discTotal = !isNaN(discParts[1]) ? discParts[1] : null
|
||||
}
|
||||
}
|
||||
this.format = data.format
|
||||
this.duration = data.duration
|
||||
this.size = data.size
|
||||
this.audioMetaTags = new AudioMetaTags()
|
||||
this.audioMetaTags.setDataFromTone(data.tags)
|
||||
}
|
||||
}
|
||||
module.exports = MediaProbeData
|
Loading…
Add table
Add a link
Reference in a new issue