mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-19 00:18:56 +01:00
Merge pull request #3921 from advplyr/fix_content_url_basepath
Fix API including basepath in tracks contentUrl
This commit is contained in:
commit
40e11db5e5
@ -414,11 +414,8 @@ export default {
|
|||||||
|
|
||||||
const audioEl = this.audioEl || document.createElement('audio')
|
const audioEl = this.audioEl || document.createElement('audio')
|
||||||
var src = audioTrack.contentUrl + `?token=${this.userToken}`
|
var src = audioTrack.contentUrl + `?token=${this.userToken}`
|
||||||
if (this.$isDev) {
|
|
||||||
src = `${process.env.serverUrl}${src}`
|
|
||||||
}
|
|
||||||
|
|
||||||
audioEl.src = src
|
audioEl.src = `${process.env.serverUrl}${src}`
|
||||||
audioEl.id = 'chapter-audio'
|
audioEl.id = 'chapter-audio'
|
||||||
document.body.appendChild(audioEl)
|
document.body.appendChild(audioEl)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export default class AudioTrack {
|
export default class AudioTrack {
|
||||||
constructor(track, userToken) {
|
constructor(track, userToken, routerBasePath) {
|
||||||
this.index = track.index || 0
|
this.index = track.index || 0
|
||||||
this.startOffset = track.startOffset || 0 // Total time of all previous tracks
|
this.startOffset = track.startOffset || 0 // Total time of all previous tracks
|
||||||
this.duration = track.duration || 0
|
this.duration = track.duration || 0
|
||||||
@ -9,20 +9,27 @@ export default class AudioTrack {
|
|||||||
this.metadata = track.metadata || {}
|
this.metadata = track.metadata || {}
|
||||||
|
|
||||||
this.userToken = userToken
|
this.userToken = userToken
|
||||||
|
this.routerBasePath = routerBasePath || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for CastPlayer
|
||||||
|
*/
|
||||||
get fullContentUrl() {
|
get fullContentUrl() {
|
||||||
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
|
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
|
||||||
}
|
}
|
||||||
return `${window.location.origin}${this.contentUrl}?token=${this.userToken}`
|
return `${window.location.origin}${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for LocalPlayer
|
||||||
|
*/
|
||||||
get relativeContentUrl() {
|
get relativeContentUrl() {
|
||||||
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
||||||
|
|
||||||
return this.contentUrl + `?token=${this.userToken}`
|
return `${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ export default class PlayerHandler {
|
|||||||
|
|
||||||
console.log('[PlayerHandler] Preparing Session', session)
|
console.log('[PlayerHandler] Preparing Session', session)
|
||||||
|
|
||||||
var audioTracks = session.audioTracks.map((at) => new AudioTrack(at, this.userToken))
|
var audioTracks = session.audioTracks.map((at) => new AudioTrack(at, this.userToken, this.ctx.$config.routerBasePath))
|
||||||
|
|
||||||
this.ctx.playerLoading = true
|
this.ctx.playerLoading = true
|
||||||
this.isHlsTranscode = true
|
this.isHlsTranscode = true
|
||||||
|
@ -286,7 +286,7 @@ class Book extends Model {
|
|||||||
const track = structuredClone(af)
|
const track = structuredClone(af)
|
||||||
track.title = af.metadata.filename
|
track.title = af.metadata.filename
|
||||||
track.startOffset = startOffset
|
track.startOffset = startOffset
|
||||||
track.contentUrl = `${global.RouterBasePath}/api/items/${libraryItemId}/file/${track.ino}`
|
track.contentUrl = `/api/items/${libraryItemId}/file/${track.ino}`
|
||||||
startOffset += track.duration
|
startOffset += track.duration
|
||||||
return track
|
return track
|
||||||
})
|
})
|
||||||
|
@ -169,7 +169,7 @@ class PodcastEpisode extends Model {
|
|||||||
const track = structuredClone(this.audioFile)
|
const track = structuredClone(this.audioFile)
|
||||||
track.startOffset = 0
|
track.startOffset = 0
|
||||||
track.title = this.audioFile.metadata.filename
|
track.title = this.audioFile.metadata.filename
|
||||||
track.contentUrl = `${global.RouterBasePath}/api/items/${libraryItemId}/file/${track.ino}`
|
track.contentUrl = `/api/items/${libraryItemId}/file/${track.ino}`
|
||||||
return track
|
return track
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class AudioTrack {
|
|||||||
this.duration = audioFile.duration
|
this.duration = audioFile.duration
|
||||||
this.title = audioFile.metadata.filename || ''
|
this.title = audioFile.metadata.filename || ''
|
||||||
|
|
||||||
this.contentUrl = `${global.RouterBasePath}/api/items/${itemId}/file/${audioFile.ino}`
|
this.contentUrl = `/api/items/${itemId}/file/${audioFile.ino}`
|
||||||
this.mimeType = audioFile.mimeType
|
this.mimeType = audioFile.mimeType
|
||||||
this.codec = audioFile.codec || null
|
this.codec = audioFile.codec || null
|
||||||
this.metadata = audioFile.metadata.clone()
|
this.metadata = audioFile.metadata.clone()
|
||||||
@ -44,4 +44,4 @@ class AudioTrack {
|
|||||||
this.mimeType = 'application/vnd.apple.mpegurl'
|
this.mimeType = 'application/vnd.apple.mpegurl'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = AudioTrack
|
module.exports = AudioTrack
|
||||||
|
Loading…
Reference in New Issue
Block a user