Merge pull request #276 from mx03/fixescapeurl

Fix: escape special characters in provider urls
This commit is contained in:
advplyr 2021-12-30 09:27:15 -06:00 committed by GitHub
commit 384d8ec423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 4 deletions

View File

@ -39,8 +39,12 @@ class Audible {
} }
asinSearch(asin) { asinSearch(asin) {
var queryString = `response_groups=rating,series,contributors,product_desc,media,product_extended_attrs` + var queryObj = {
`&image_sizes=500,1024,2000`; response_groups: 'rating,series,contributors,product_desc,media,product_extended_attrs',
image_sizes: '500,1024,2000'
};
var queryString = (new URLSearchParams(queryObj)).toString();
asin = encodeURIComponent(asin);
var url = `https://api.audible.com/1.0/catalog/products/${asin}?${queryString}` var url = `https://api.audible.com/1.0/catalog/products/${asin}?${queryString}`
Logger.debug(`[Audible] ASIN url: ${url}`) Logger.debug(`[Audible] ASIN url: ${url}`)
return axios.get(url).then((res) => { return axios.get(url).then((res) => {

View File

@ -8,6 +8,7 @@ class Audnexus {
} }
authorASINsRequest(name) { authorASINsRequest(name) {
name = encodeURIComponent(name);
return axios.get(`${this.baseUrl}/authors?name=${name}`).then((res) => { return axios.get(`${this.baseUrl}/authors?name=${name}`).then((res) => {
return res.data || [] return res.data || []
}).catch((error) => { }).catch((error) => {
@ -17,6 +18,7 @@ class Audnexus {
} }
authorRequest(asin) { authorRequest(asin) {
asin = encodeURIComponent(asin);
return axios.get(`${this.baseUrl}/authors/${asin}`).then((res) => { return axios.get(`${this.baseUrl}/authors/${asin}`).then((res) => {
return res.data return res.data
}).catch((error) => { }).catch((error) => {

View File

@ -32,8 +32,12 @@ class GoogleBooks {
} }
async search(title, author) { async search(title, author) {
title = encodeURIComponent(title)
var queryString = `q=intitle:${title}` var queryString = `q=intitle:${title}`
if (author) queryString += `+inauthor:${author}` if (author) {
author = encodeURIComponent(author)
queryString += `+inauthor:${author}`
}
var url = `https://www.googleapis.com/books/v1/volumes?${queryString}` var url = `https://www.googleapis.com/books/v1/volumes?${queryString}`
Logger.debug(`[GoogleBooks] Search url: ${url}`) Logger.debug(`[GoogleBooks] Search url: ${url}`)
var items = await axios.get(url).then((res) => { var items = await axios.get(url).then((res) => {

View File

@ -15,6 +15,7 @@ class LibGen {
await this.init() await this.init()
} }
queryTitle = queryTitle.replace(/'/g, '') queryTitle = queryTitle.replace(/'/g, '')
queryTitle = encodeURIComponent(queryTitle);
var options = { var options = {
mirror: this.mirror, mirror: this.mirror,
query: queryTitle, query: queryTitle,

View File

@ -85,7 +85,7 @@ class OpenLibrary {
} }
async searchTitle(title) { async searchTitle(title) {
title = title.replace(/'/g, '') title = encodeURIComponent(title);
var lookupData = await this.get(`/search.json?title=${title}`) var lookupData = await this.get(`/search.json?title=${title}`)
if (!lookupData) { if (!lookupData) {
return { return {