Fixed a issue where the tmdb type was not being selected correctly. (movie/show)
This commit is contained in:
@@ -76,9 +76,9 @@ class TMDB {
|
|||||||
* @returns {Promise} succeeds if movie was found
|
* @returns {Promise} succeeds if movie was found
|
||||||
*/
|
*/
|
||||||
lookup(identifier, queryType = 'movie') {
|
lookup(identifier, queryType = 'movie') {
|
||||||
var type;
|
var type, tmdbType;
|
||||||
if (queryType === 'movie') { type = 'movieInfo'}
|
if (queryType === 'movie' || queryType === 'movieInfo') { type = 'movie', tmdbType = 'movieInfo' }
|
||||||
else if (queryType === 'show') { type = 'tvInfo'}
|
else if (queryType === 'show' || queryType === 'tvInfo') { type = 'show', tmdbType = 'tvInfo' }
|
||||||
else {
|
else {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -89,14 +89,12 @@ class TMDB {
|
|||||||
const cacheKey = `${this.cacheTags.lookup}:${type}:${identifier}`;
|
const cacheKey = `${this.cacheTags.lookup}:${type}:${identifier}`;
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(() => this.cache.get(cacheKey))
|
.then(() => this.cache.get(cacheKey))
|
||||||
.catch(() => this.tmdb(type, query))
|
.catch(() => this.tmdb(tmdbType, query))
|
||||||
.catch(() => { throw new Error('Could not find a movie with that id.'); })
|
.catch(() => { throw new Error('Could not find a movie with that id.'); })
|
||||||
.then((response) => this.cache.set(cacheKey, response))
|
.then((response) => this.cache.set(cacheKey, response))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
try {
|
try {
|
||||||
var car = convertTmdbToSeasoned(response, queryType);
|
return convertTmdbToSeasoned(response, type);
|
||||||
console.log(car);
|
|
||||||
return car;
|
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
throw new Error('Could not parse movie.');
|
throw new Error('Could not parse movie.');
|
||||||
}
|
}
|
||||||
@@ -142,7 +140,6 @@ class TMDB {
|
|||||||
const mappedResults = response.results.map((result) => {
|
const mappedResults = response.results.map((result) => {
|
||||||
return convertTmdbToSeasoned(result, type)
|
return convertTmdbToSeasoned(result, type)
|
||||||
})
|
})
|
||||||
|
|
||||||
return [mappedResults, response.page, response.total_pages]
|
return [mappedResults, response.page, response.total_pages]
|
||||||
})
|
})
|
||||||
.catch((error) => { throw new Error(error)})
|
.catch((error) => { throw new Error(error)})
|
||||||
|
|||||||
Reference in New Issue
Block a user