mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Fix:Encode filename for audio player direct plays
This commit is contained in:
parent
9f29b245d7
commit
83976b5549
@ -96,12 +96,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getRelativePath(path) {
|
getRelativePath(path) {
|
||||||
var filePath = path.replace(/\\/g, '/')
|
var relativePath = path.replace(/\\/g, '/').replace(this.audiobookPath.replace(/\\/g, '/') + '/', '')
|
||||||
var audiobookPath = this.audiobookPath.replace(/\\/g, '/')
|
return this.$encodeUriPath(relativePath)
|
||||||
return filePath
|
|
||||||
.replace(audiobookPath + '/', '')
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/#/g, '%23')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
|
@ -71,15 +71,9 @@ export default {
|
|||||||
},
|
},
|
||||||
otherFilesCleaned() {
|
otherFilesCleaned() {
|
||||||
return this.files.map((file) => {
|
return this.files.map((file) => {
|
||||||
var filePath = file.path.replace(/\\/g, '/')
|
|
||||||
var audiobookPath = this.audiobookPath.replace(/\\/g, '/')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...file,
|
...file,
|
||||||
relativePath: filePath
|
relativePath: this.getRelativePath(file.path)
|
||||||
.replace(audiobookPath + '/', '')
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/#/g, '%23')
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -99,6 +93,10 @@ export default {
|
|||||||
},
|
},
|
||||||
clickBar() {
|
clickBar() {
|
||||||
this.showFiles = !this.showFiles
|
this.showFiles = !this.showFiles
|
||||||
|
},
|
||||||
|
getRelativePath(path) {
|
||||||
|
var relativePath = path.replace(/\\/g, '/').replace(this.audiobookPath.replace(/\\/g, '/') + '/', '')
|
||||||
|
return this.$encodeUriPath(relativePath)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
|
@ -75,15 +75,9 @@ export default {
|
|||||||
},
|
},
|
||||||
tracksCleaned() {
|
tracksCleaned() {
|
||||||
return this.tracks.map((track) => {
|
return this.tracks.map((track) => {
|
||||||
var trackPath = track.path.replace(/\\/g, '/')
|
|
||||||
var audiobookPath = this.audiobookPath.replace(/\\/g, '/')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...track,
|
...track,
|
||||||
relativePath: trackPath
|
relativePath: this.getRelativePath(track.path)
|
||||||
.replace(audiobookPath + '/', '')
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/#/g, '%23')
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -100,6 +94,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
clickBar() {
|
clickBar() {
|
||||||
this.showTracks = !this.showTracks
|
this.showTracks = !this.showTracks
|
||||||
|
},
|
||||||
|
getRelativePath(path) {
|
||||||
|
var relativePath = path.replace(/\\/g, '/').replace(this.audiobookPath.replace(/\\/g, '/') + '/', '')
|
||||||
|
return this.$encodeUriPath(relativePath)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
|
@ -132,7 +132,7 @@ export default class PlayerHandler {
|
|||||||
var audioTracks = (this.audiobook.tracks || []).map((track) => {
|
var audioTracks = (this.audiobook.tracks || []).map((track) => {
|
||||||
var audioTrack = new AudioTrack(track)
|
var audioTrack = new AudioTrack(track)
|
||||||
audioTrack.startOffset = runningTotal
|
audioTrack.startOffset = runningTotal
|
||||||
audioTrack.contentUrl = `/lib/${this.audiobook.libraryId}/${this.audiobook.folderId}/${track.path}?token=${this.userToken}`
|
audioTrack.contentUrl = `/lib/${this.audiobook.libraryId}/${this.audiobook.folderId}/${this.ctx.$encodeUriPath(track.path)}?token=${this.userToken}`
|
||||||
audioTrack.mimeType = this.getMimeTypeForTrack(track)
|
audioTrack.mimeType = this.getMimeTypeForTrack(track)
|
||||||
audioTrack.canDirectPlay = !!this.player.playableMimetypes[audioTrack.mimeType]
|
audioTrack.canDirectPlay = !!this.player.playableMimetypes[audioTrack.mimeType]
|
||||||
|
|
||||||
|
@ -138,6 +138,10 @@ function xmlToJson(xml) {
|
|||||||
}
|
}
|
||||||
Vue.prototype.$xmlToJson = xmlToJson
|
Vue.prototype.$xmlToJson = xmlToJson
|
||||||
|
|
||||||
|
Vue.prototype.$encodeUriPath = (path) => {
|
||||||
|
return path.replace(/\\/g, '/').replace(/%/g, '%25').replace(/#/g, '%23')
|
||||||
|
}
|
||||||
|
|
||||||
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
||||||
Vue.prototype.$encode = encode
|
Vue.prototype.$encode = encode
|
||||||
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
||||||
|
Loading…
Reference in New Issue
Block a user