mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-24 22:47:09 -04:00
Add global search, add reset all audiobooks
This commit is contained in:
parent
5b64453101
commit
0990c61c93
18 changed files with 323 additions and 33 deletions
|
@ -17,8 +17,9 @@ class ApiController {
|
|||
this.router.get('/find/covers', this.findCovers.bind(this))
|
||||
this.router.get('/find/:method', this.find.bind(this))
|
||||
|
||||
|
||||
this.router.get('/audiobooks', this.getAudiobooks.bind(this))
|
||||
this.router.delete('/audiobooks', this.deleteAllAudiobooks.bind(this))
|
||||
|
||||
this.router.get('/audiobook/:id', this.getAudiobook.bind(this))
|
||||
this.router.delete('/audiobook/:id', this.deleteAudiobook.bind(this))
|
||||
this.router.patch('/audiobook/:id/tracks', this.updateAudiobookTracks.bind(this))
|
||||
|
@ -57,9 +58,22 @@ class ApiController {
|
|||
}
|
||||
|
||||
getAudiobooks(req, res) {
|
||||
Logger.info('Get Audiobooks')
|
||||
var audiobooksMinified = this.db.audiobooks.map(ab => ab.toJSONMinified())
|
||||
res.json(audiobooksMinified)
|
||||
var audiobooks = []
|
||||
if (req.query.q) {
|
||||
audiobooks = this.db.audiobooks.filter(ab => {
|
||||
return ab.isSearchMatch(req.query.q)
|
||||
}).map(ab => ab.toJSONMinified())
|
||||
} else {
|
||||
audiobooks = this.db.audiobooks.map(ab => ab.toJSONMinified())
|
||||
}
|
||||
res.json(audiobooks)
|
||||
}
|
||||
|
||||
async deleteAllAudiobooks(req, res) {
|
||||
Logger.info('Removing all Audiobooks')
|
||||
var success = await this.db.recreateAudiobookDb()
|
||||
if (success) res.sendStatus(200)
|
||||
else res.sendStatus(500)
|
||||
}
|
||||
|
||||
getAudiobook(req, res) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue