mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 09:14:40 +02:00
Add sync local media progress routes for offline mobile playback session support
This commit is contained in:
parent
fc228013d3
commit
2a386ca2a9
7 changed files with 113 additions and 63 deletions
|
@ -135,6 +135,7 @@ class ApiRouter {
|
|||
this.router.delete('/me/item/:id/bookmark/:time', MeController.removeBookmark.bind(this))
|
||||
this.router.patch('/me/password', MeController.updatePassword.bind(this))
|
||||
this.router.patch('/me/settings', MeController.updateSettings.bind(this))
|
||||
this.router.post('/me/sync-local-progress', MeController.syncLocalMediaProgress.bind(this))
|
||||
|
||||
//
|
||||
// Backup Routes
|
||||
|
@ -169,6 +170,7 @@ class ApiRouter {
|
|||
//
|
||||
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/local', SessionController.syncLocal.bind(this))
|
||||
|
||||
//
|
||||
// Podcast Routes
|
||||
|
@ -192,9 +194,6 @@ class ApiRouter {
|
|||
this.router.get('/search/podcast', MiscController.findPodcasts.bind(this))
|
||||
this.router.get('/search/authors', MiscController.findAuthor.bind(this))
|
||||
this.router.get('/tags', MiscController.getAllTags.bind(this))
|
||||
|
||||
// OLD
|
||||
// this.router.post('/syncUserAudiobookData', this.syncUserAudiobookData.bind(this))
|
||||
}
|
||||
|
||||
async getDirectories(dir, relpath, excludedDirs, level = 0) {
|
||||
|
@ -226,38 +225,6 @@ class ApiRouter {
|
|||
}
|
||||
}
|
||||
|
||||
async syncUserAudiobookData(req, res) {
|
||||
// if (!req.body.data) {
|
||||
// return res.status(403).send('Invalid local user audiobook data')
|
||||
// }
|
||||
|
||||
// var hasUpdates = false
|
||||
|
||||
// // Local user audiobook data use the latest update
|
||||
// req.body.data.forEach((uab) => {
|
||||
// if (!uab || !uab.audiobookId) {
|
||||
// Logger.error('[ApiController] Invalid user audiobook data', uab)
|
||||
// return
|
||||
// }
|
||||
// var audiobook = this.db.audiobooks.find(ab => ab.id === uab.audiobookId)
|
||||
// if (!audiobook) {
|
||||
// Logger.info('[ApiController] syncUserAudiobookData local audiobook data audiobook no longer exists', uab.audiobookId)
|
||||
// return
|
||||
// }
|
||||
// if (req.user.syncLocalUserAudiobookData(uab, audiobook)) {
|
||||
// this.clientEmitter(req.user.id, 'current_user_audiobook_update', { id: uab.audiobookId, data: uab })
|
||||
// hasUpdates = true
|
||||
// }
|
||||
// })
|
||||
|
||||
// if (hasUpdates) {
|
||||
// await this.db.updateEntity('user', req.user)
|
||||
// }
|
||||
|
||||
// var allUserAudiobookData = Object.values(req.user.audiobooksToJSON())
|
||||
// res.json(allUserAudiobookData)
|
||||
}
|
||||
|
||||
//
|
||||
// Helper Methods
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue