Add:Select cover search provider, Add:Persist selected provider, Change:API routes for searching

This commit is contained in:
advplyr 2021-12-07 18:42:56 -06:00
parent bb1a5b2e6d
commit c5465ad8e0
4 changed files with 82 additions and 26 deletions

View file

@ -40,10 +40,6 @@ class ApiController {
}
init() {
this.router.get('/find/covers', this.findCovers.bind(this))
this.router.get('/find/:method', this.find.bind(this))
//
// Library Routes
//
@ -149,6 +145,12 @@ class ApiController {
this.router.delete('/backup/:id', BackupController.delete.bind(this))
this.router.post('/backup/upload', BackupController.upload.bind(this))
//
// Search Routes
//
this.router.get('/search/covers', this.findCovers.bind(this))
this.router.get('/search/books', this.findBooks.bind(this))
//
// Others
//
@ -174,16 +176,21 @@ class ApiController {
this.router.post('/syncUserAudiobookData', this.syncUserAudiobookData.bind(this))
}
async find(req, res) {
var provider = req.query.provider || 'google'
async findBooks(req, res) {
if (req.method === 'match') {
} else if (req.method === 'cover')
var provider = req.query.provider || 'google'
var title = req.query.title || ''
var author = req.query.author || ''
var results = await this.bookFinder.search(provider, title, author)
res.json(results)
}
findCovers(req, res) {
this.scanner.findCovers(req, res)
async findCovers(req, res) {
var query = req.query
var result = await this.bookFinder.findCovers(query.provider, query.title, query.author || null)
res.json(result)
}
authorize(req, res) {