Merge pull request #31 from KevinMidboe/fix/seasonedApiSearch

Fix/seasoned api search
This commit is contained in:
2017-09-21 16:39:00 +02:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -2,7 +2,10 @@ const Movie = require('src/media_classes/movie');
const Show = require('src/media_classes/show');
function convertTmdbToSeasoned(tmdbObject, strictType=undefined) {
const mediaType = strictType || tmdbObject.media_type;
if (strictType === undefined)
var mediaType = tmdbObject.media_type;
else
var mediaType = strictType;
// There are many diff types of content, we only want to look at movies and tv shows
if (mediaType === 'movie') {
@@ -47,4 +50,5 @@ function convertTmdbToSeasoned(tmdbObject, strictType=undefined) {
}
}
module.exports = convertTmdbToSeasoned;
module.exports = convertTmdbToSeasoned;

View File

@@ -31,7 +31,12 @@ class TMDB {
// Here we convert the filtered result from the tmdb api to seaonsed objects
let seasonedItems = filteredTmdbItems.map((tmdbItem) => {
return convertTmdbToSeasoned(tmdbItem);
if (type === 'movie')
return convertTmdbToSeasoned(tmdbItem, 'movie');
else if (type === 'show')
return convertTmdbToSeaosned(tmdbItem, 'show');
else
return convertTmdbToSeasoned(tmdbItem);
});
// TODO add page number if results are larger than 20
@@ -294,4 +299,4 @@ class TMDB {
}
}
module.exports = TMDB;
module.exports = TMDB;