Merge pull request #20 from KevinMidboe/api_bugfixing

Api bugfixing and changed value of filter for tmdb search
This commit is contained in:
2017-09-02 22:54:09 +02:00
committed by GitHub
3 changed files with 16 additions and 4 deletions

View File

@@ -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;
});
}

View File

@@ -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;
}
}

View File

@@ -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.');
}
});