From 84a897da6e9af1be862fde3288b68aa78694a6ed Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Sep 2017 22:51:49 +0200 Subject: [PATCH 1/2] Added popularity and vote_count to movie and show object and added a new check for name and title of movie --- seasoned_api/src/plex/requestRepository.js | 3 +-- seasoned_api/src/tmdb/convertTmdbToSeasoned.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index ee3f90d..8aef0ca 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -28,7 +28,7 @@ class RequestRepository { return Promise.each(plexMedia, function(plexMovie) { if (tmdbMovie.title == plexMovie.title && tmdbMovie.year == plexMovie.year) { tmdbMovie.matchedInPlex = true; - console.log(tmdbMovie.title + ' : ' + tmdbMovie.year); + // console.log('Matched: ' + tmdbMovie.title + ' : ' + tmdbMovie.year); } return tmdbMovie; }) @@ -41,7 +41,6 @@ class RequestRepository { }) }) .catch((error) => { - console.log(error); return error; }); } diff --git a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js index 3f6c65e..3bbfd38 100644 --- a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js +++ b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js @@ -10,7 +10,13 @@ function convertTmdbToSeasoned(tmdbObject) { if (mediaType === 'movie') { const year = new Date(tmdbObject.release_date).getFullYear(); - const movie = new Movie(tmdbObject.title, year, mediaType); + if (tmdbObject.title !== undefined) { + var title = tmdbObject.title; + } else if (tmdbObject.name !== undefined) { + var title = tmdbObject.name; + } + + const movie = new Movie(title, year, mediaType); movie.summary = tmdbObject.overview; movie.rating = tmdbObject.vote_average; @@ -18,6 +24,9 @@ function convertTmdbToSeasoned(tmdbObject) { movie.background = tmdbObject.backdrop_path; movie.genre = tmdbObject.genre_ids; + movie.popularity = tmdbObject.popularity; + movie.vote_count = tmdbObject.vote_count; + return movie; } else if (mediaType === 'tv') { @@ -31,6 +40,9 @@ function convertTmdbToSeasoned(tmdbObject) { show.background = tmdbObject.backdrop_path; show.genre = tmdbObject.genre_ids; + show.popularity = tmdbObject.popularity; + show.vote_count = tmdbObject.vote_count; + return show; } } From dacd44a8f551e958f1724104ca3353bfa5847bff Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Sep 2017 22:53:04 +0200 Subject: [PATCH 2/2] Changed the value of the filter to be vote_count >= 80 or popularity > 18 --- seasoned_api/src/tmdb/tmdb.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 6d9f18f..a536381 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -16,9 +16,10 @@ class TMDB { .then((reponse) => { try { return reponse.results.filter(function(item) { - return ((item.vote_count >= 20 || item.popularity > 2) && (item.release_date !== undefined || item.first_air_date !== undefined)) + return ((item.vote_count >= 80 || item.popularity > 18) && (item.release_date !== undefined || item.first_air_date !== undefined)) }).map(convertTmdbToSeasoned); } catch (parseError) { + console.log(parseError) throw new Error('Could not parse result.'); } });