Update get tags route and revert podcast/books search route

This commit is contained in:
advplyr 2022-12-12 17:45:51 -06:00
parent 0ae853c119
commit 2d9035d90b
4 changed files with 31 additions and 30 deletions

View file

@ -4,16 +4,15 @@ class SearchController {
constructor() { }
async findBooks(req, res) {
var provider = req.query.provider || 'google'
var title = req.query.title || ''
var author = req.query.author || ''
res.json({
results: await this.bookFinder.search(provider, title, author)
})
const provider = req.query.provider || 'google'
const title = req.query.title || ''
const author = req.query.author || ''
const results = await this.bookFinder.search(provider, title, author)
res.json(results)
}
async findCovers(req, res) {
var query = req.query
const query = req.query
const podcast = query.podcast == 1
if (!query.title) {
@ -21,31 +20,30 @@ class SearchController {
return res.sendStatus(400)
}
var result = null
if (podcast) result = await this.podcastFinder.findCovers(query.title)
else result = await this.bookFinder.findCovers(query.provider || 'google', query.title, query.author || null)
let results = null
if (podcast) results = await this.podcastFinder.findCovers(query.title)
else results = await this.bookFinder.findCovers(query.provider || 'google', query.title, query.author || null)
res.json({
results: result
results
})
}
async findPodcasts(req, res) {
var term = req.query.term
res.json({
results: await this.podcastFinder.search(term)
})
const term = req.query.term
const results = await this.podcastFinder.search(term)
res.json(results)
}
async findAuthor(req, res) {
var query = req.query.q
var author = await this.authorFinder.findAuthorByName(query)
const query = req.query.q
const author = await this.authorFinder.findAuthorByName(query)
res.json(author)
}
async findChapters(req, res) {
var asin = req.query.asin
var region = (req.query.region || 'us').toLowerCase()
var chapterData = await this.bookFinder.findChapters(asin, region)
const asin = req.query.asin
const region = (req.query.region || 'us').toLowerCase()
const chapterData = await this.bookFinder.findChapters(asin, region)
if (!chapterData) {
return res.json({ error: 'Chapters not found' })
}