Fix/seasoned api search #31

Merged
KevinMidboe merged 2 commits from fix/seasonedApiSearch into master 2017-09-21 14:39:01 +00:00
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') {
@@ -48,3 +51,4 @@ function convertTmdbToSeasoned(tmdbObject, strictType=undefined) {
}
module.exports = convertTmdbToSeasoned;

View File

@@ -31,6 +31,11 @@ class TMDB {
// Here we convert the filtered result from the tmdb api to seaonsed objects
let seasonedItems = filteredTmdbItems.map((tmdbItem) => {
if (type === 'movie')
return convertTmdbToSeasoned(tmdbItem, 'movie');
else if (type === 'show')
return convertTmdbToSeaosned(tmdbItem, 'show');
else
return convertTmdbToSeasoned(tmdbItem);
});