From 743c132aefb6848b85ca1464e153bb6adda1cfb5 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Thu, 21 Sep 2017 16:37:10 +0200 Subject: [PATCH 1/3] If a strict type is passed to convertTmdbToSeasoned than this is now used to set the type of objects to be made. --- seasoned_api/src/tmdb/convertTmdbToSeasoned.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js index 7379610..79f2d00 100644 --- a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js +++ b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js @@ -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; \ No newline at end of file +module.exports = convertTmdbToSeasoned; + From e281e73293797a472409a69855412515db10f5e4 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Thu, 21 Sep 2017 16:37:53 +0200 Subject: [PATCH 2/3] Now the type is checked and passed to convertTmdbToSeasoned if it is movie or show and not multiwq --- seasoned_api/src/tmdb/tmdb.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 3657679..0557a2f 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -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; \ No newline at end of file +module.exports = TMDB; From 6b4daf140afe5297e2e3ce4be5c272c9d95d28b8 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Thu, 21 Sep 2017 16:58:44 +0200 Subject: [PATCH 3/3] Change a grammar error --- seasoned_api/src/tmdb/tmdb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 0557a2f..236c1de 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -34,7 +34,7 @@ class TMDB { if (type === 'movie') return convertTmdbToSeasoned(tmdbItem, 'movie'); else if (type === 'show') - return convertTmdbToSeaosned(tmdbItem, 'show'); + return convertTmdbToSeasoned(tmdbItem, 'show'); else return convertTmdbToSeasoned(tmdbItem); });