mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-21 08:36:03 +02:00
Update:Validate ASIN for author, chapter and match requests
This commit is contained in:
parent
ee501f70ed
commit
a018374d26
5 changed files with 72 additions and 45 deletions
|
@ -1,12 +1,13 @@
|
|||
const Logger = require("../Logger")
|
||||
const Logger = require('../Logger')
|
||||
const BookFinder = require('../finders/BookFinder')
|
||||
const PodcastFinder = require('../finders/PodcastFinder')
|
||||
const AuthorFinder = require('../finders/AuthorFinder')
|
||||
const MusicFinder = require('../finders/MusicFinder')
|
||||
const Database = require("../Database")
|
||||
const Database = require('../Database')
|
||||
const { isValidASIN } = require('../utils')
|
||||
|
||||
class SearchController {
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
async findBooks(req, res) {
|
||||
const id = req.query.id
|
||||
|
@ -37,9 +38,9 @@ class SearchController {
|
|||
|
||||
/**
|
||||
* Find podcast RSS feeds given a term
|
||||
*
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} res
|
||||
*
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} res
|
||||
*/
|
||||
async findPodcasts(req, res) {
|
||||
const term = req.query.term
|
||||
|
@ -63,6 +64,9 @@ class SearchController {
|
|||
|
||||
async findChapters(req, res) {
|
||||
const asin = req.query.asin
|
||||
if (!isValidASIN(asin.toUpperCase())) {
|
||||
return res.json({ error: 'Invalid ASIN' })
|
||||
}
|
||||
const region = (req.query.region || 'us').toLowerCase()
|
||||
const chapterData = await BookFinder.findChapters(asin, region)
|
||||
if (!chapterData) {
|
||||
|
@ -78,4 +82,4 @@ class SearchController {
|
|||
})
|
||||
}
|
||||
}
|
||||
module.exports = new SearchController()
|
||||
module.exports = new SearchController()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue