mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-29 01:08:56 +01:00
Update:API route for getting playback session and getting media progress
This commit is contained in:
parent
792490b629
commit
bf928692d5
@ -16,6 +16,15 @@ class MeController {
|
|||||||
res.json(listeningStats)
|
res.json(listeningStats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET: api/me/progress/:id/:episodeId?
|
||||||
|
async getMediaProgress(req, res) {
|
||||||
|
const mediaProgress = req.user.getMediaProgress(req.id, req.episodeId || null)
|
||||||
|
if (!mediaProgress) {
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
res.json(mediaProgress)
|
||||||
|
}
|
||||||
|
|
||||||
// DELETE: api/me/progress/:id
|
// DELETE: api/me/progress/:id
|
||||||
async removeMediaProgress(req, res) {
|
async removeMediaProgress(req, res) {
|
||||||
var wasRemoved = req.user.removeMediaProgress(req.params.id)
|
var wasRemoved = req.user.removeMediaProgress(req.params.id)
|
||||||
|
@ -7,6 +7,12 @@ class SessionController {
|
|||||||
return res.json(req.session)
|
return res.json(req.session)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSession(req, res) {
|
||||||
|
var libraryItem = this.db.getLibraryItem(req.session.libraryItemId)
|
||||||
|
var sessionForClient = req.session.toJSONForClient(libraryItem)
|
||||||
|
res.json(sessionForClient)
|
||||||
|
}
|
||||||
|
|
||||||
// POST: api/session/:id/sync
|
// POST: api/session/:id/sync
|
||||||
sync(req, res) {
|
sync(req, res) {
|
||||||
this.playbackSessionManager.syncSessionRequest(req.user, req.session, req.body, res)
|
this.playbackSessionManager.syncSessionRequest(req.user, req.session, req.body, res)
|
||||||
|
@ -131,6 +131,7 @@ class ApiRouter {
|
|||||||
//
|
//
|
||||||
this.router.get('/me/listening-sessions', MeController.getListeningSessions.bind(this))
|
this.router.get('/me/listening-sessions', MeController.getListeningSessions.bind(this))
|
||||||
this.router.get('/me/listening-stats', MeController.getListeningStats.bind(this))
|
this.router.get('/me/listening-stats', MeController.getListeningStats.bind(this))
|
||||||
|
this.router.get('/me/progress/:id/:episodeId?', MeController.getMediaProgress.bind(this))
|
||||||
this.router.patch('/me/progress/batch/update', MeController.batchUpdateMediaProgress.bind(this))
|
this.router.patch('/me/progress/batch/update', MeController.batchUpdateMediaProgress.bind(this))
|
||||||
this.router.patch('/me/progress/:id', MeController.createUpdateMediaProgress.bind(this))
|
this.router.patch('/me/progress/:id', MeController.createUpdateMediaProgress.bind(this))
|
||||||
this.router.delete('/me/progress/:id', MeController.removeMediaProgress.bind(this))
|
this.router.delete('/me/progress/:id', MeController.removeMediaProgress.bind(this))
|
||||||
@ -173,6 +174,7 @@ class ApiRouter {
|
|||||||
//
|
//
|
||||||
// Playback Session Routes
|
// Playback Session Routes
|
||||||
//
|
//
|
||||||
|
this.router.get('/session/:id', SessionController.middleware.bind(this), SessionController.getSession.bind(this))
|
||||||
this.router.post('/session/:id/sync', SessionController.middleware.bind(this), SessionController.sync.bind(this))
|
this.router.post('/session/:id/sync', SessionController.middleware.bind(this), SessionController.sync.bind(this))
|
||||||
this.router.post('/session/:id/close', SessionController.middleware.bind(this), SessionController.close.bind(this))
|
this.router.post('/session/:id/close', SessionController.middleware.bind(this), SessionController.close.bind(this))
|
||||||
this.router.post('/session/local', SessionController.syncLocal.bind(this))
|
this.router.post('/session/local', SessionController.syncLocal.bind(this))
|
||||||
|
Loading…
Reference in New Issue
Block a user