Add: api endpoint for starting streams for android auto support

This commit is contained in:
advplyr 2021-11-11 08:39:21 -06:00
parent 2451861e0e
commit 663d02e9fe
5 changed files with 58 additions and 22 deletions

View file

@ -57,6 +57,7 @@ class ApiController {
this.router.post('/audiobook/:id/cover', this.uploadAudiobookCover.bind(this))
this.router.patch('/audiobook/:id/coverfile', this.updateAudiobookCoverFromFile.bind(this))
this.router.get('/audiobook/:id/match', this.matchAudiobookBook.bind(this))
this.router.get('/audiobook/:id/stream', this.openAudiobookStream.bind(this))
this.router.patch('/audiobook/:id', this.updateAudiobook.bind(this))
this.router.patch('/match/:id', this.match.bind(this))
@ -541,6 +542,13 @@ class ApiController {
res.json(results)
}
async openAudiobookStream(req, res) {
var audiobook = this.db.audiobooks.find(a => a.id === req.params.id)
if (!audiobook) return res.sendStatus(404)
this.streamManager.openStreamApiRequest(res, req.user, audiobook)
}
async updateAudiobook(req, res) {
if (!req.user.canUpdate) {
Logger.warn('User attempted to update without permission', req.user)