Add autoplay for next book in series after queue ends

This commit is contained in:
Vito0912 2025-09-25 09:43:38 +02:00
parent e040396b20
commit 0610cca7b1
No known key found for this signature in database
GPG key ID: A0F767011D6093A2
3 changed files with 93 additions and 22 deletions

View file

@ -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