Don't pass 'all' subgenre in discover
This commit is contained in:
parent
ced83e862a
commit
eb64ea9c96
12
lib/index.js
12
lib/index.js
|
@ -15,7 +15,15 @@ async function discover(params, options = {}) {
|
||||||
let resultParams;
|
let resultParams;
|
||||||
return sanitizeDiscoverParams(params)
|
return sanitizeDiscoverParams(params)
|
||||||
.then( sanitizedParams => {
|
.then( sanitizedParams => {
|
||||||
resultParams = sanitizedParams;
|
resultParams = Object.assign({}, sanitizedParams);
|
||||||
|
// Passing an 'all' type subgenre (e.g. 'all-metal') in the discover url
|
||||||
|
// actually returns far fewer / zero results than without.
|
||||||
|
// The Bandcamp site also does not seem to include it in its discover requests...
|
||||||
|
if (sanitizedParams.time !== undefined) {
|
||||||
|
// If 'time' exists in sanitized params, then we have an 'all' type subgenre
|
||||||
|
// - refer to sanitizeDiscoverParams()
|
||||||
|
delete sanitizedParams.subgenre;
|
||||||
|
}
|
||||||
return utils.getDiscoverUrl(sanitizedParams);
|
return utils.getDiscoverUrl(sanitizedParams);
|
||||||
})
|
})
|
||||||
.then( url => fetch(url) )
|
.then( url => fetch(url) )
|
||||||
|
@ -54,6 +62,8 @@ async function sanitizeDiscoverParams(params) {
|
||||||
if (subgenreOptions) { // false if genre is 'all'
|
if (subgenreOptions) { // false if genre is 'all'
|
||||||
sanitized.subgenre = getOptionValue(subgenreOptions, params.subgenre);
|
sanitized.subgenre = getOptionValue(subgenreOptions, params.subgenre);
|
||||||
}
|
}
|
||||||
|
// 'Time' option only available when there is effectively no subgenre (e.g. genre is 'all'
|
||||||
|
// or subgenre is 'all-metal')
|
||||||
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre == subgenreOptions[0].value;
|
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre == subgenreOptions[0].value;
|
||||||
if (timeAllowed) {
|
if (timeAllowed) {
|
||||||
sanitized.time = getOptionValue(options.times, params.time);
|
sanitized.time = getOptionValue(options.times, params.time);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user