mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-27 14:19:38 +00:00
Add autoplay for next book in series after queue ends
This commit is contained in:
parent
e040396b20
commit
0610cca7b1
3 changed files with 93 additions and 22 deletions
|
|
@ -86,6 +86,30 @@ class SeriesController {
|
|||
res.json(req.series.toOldJSON())
|
||||
}
|
||||
|
||||
/**
|
||||
* GET: /api/series/:id/next-book/:libraryItemId
|
||||
* Get the next book in a series after the given library item
|
||||
*
|
||||
* @param {SeriesControllerRequest} req
|
||||
* @param {Response} res
|
||||
*/
|
||||
async getNextBook(req, res) {
|
||||
const currentLibraryItemId = req.params.libraryItemId
|
||||
const libraryItems = req.libraryItemsInSeries
|
||||
|
||||
const currentBookIndex = libraryItems.findIndex((li) => li.id === currentLibraryItemId)
|
||||
if (currentBookIndex === -1) {
|
||||
return res.status(404).send('Current book not found in series')
|
||||
}
|
||||
|
||||
if (currentBookIndex >= libraryItems.length - 1) {
|
||||
return res.status(404).send('No next book in series')
|
||||
}
|
||||
|
||||
const nextBook = libraryItems[currentBookIndex + 1]
|
||||
res.json(nextBook.toOldJSONExpanded())
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {RequestWithUser} req
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue