Update Book.js to return array of AudioTrack objects on json expand

This commit is contained in:
advplyr 2022-04-03 16:01:59 -05:00
parent 609bf4309f
commit 6e5e638076
7 changed files with 33 additions and 20 deletions

View file

@ -1,5 +1,6 @@
const Path = require('path')
const { encodeUriPath } = require('../../utils/index')
class AudioTrack {
constructor() {
this.index = null
@ -8,6 +9,7 @@ class AudioTrack {
this.title = null
this.contentUrl = null
this.mimeType = null
this.metadata = null
}
toJSON() {
@ -17,7 +19,8 @@ class AudioTrack {
duration: this.duration,
title: this.title,
contentUrl: this.contentUrl,
mimeType: this.mimeType
mimeType: this.mimeType,
metadata: this.metadata ? this.metadata.toJSON() : null
}
}
@ -28,6 +31,7 @@ class AudioTrack {
this.title = audioFile.metadata.filename || ''
this.contentUrl = Path.join(`/s/item/${itemId}`, encodeUriPath(audioFile.metadata.relPath))
this.mimeType = audioFile.mimeType
this.metadata = audioFile.metadata.clone()
}
setFromStream(title, duration, contentUrl) {