All converter function from tmdb to movie, show and person takes optional cast object and maps to response

This commit is contained in:
2019-06-04 23:35:21 +02:00
parent 99bab3fb73
commit 70f6497404
3 changed files with 15 additions and 3 deletions

View File

@@ -2,11 +2,15 @@ const Movie = require('src/tmdb/types/movie');
const tmdbSwitcher = (tmdbMovie, property) => tmdbMovie[property]
function convertTmdbToMovie(tmdbMovie) {
function convertTmdbToMovie(tmdbMovie, credits=undefined) {
const movie = new Movie(tmdbMovie.id, tmdbMovie.title)
movie.overview = tmdbMovie.overview;
movie.rank = tmdbMovie.vote_average;
if (credits) {
movie.credits = credits;
}
if (tmdbMovie.release_date !== undefined) {
movie.release_date = new Date(tmdbMovie.release_date);
movie.year = movie.release_date.getFullYear();