Rewrote every function for searching and looking up items from tmdb library. Now there are separate functions for the four categories of search and three for info (multi, movie, show & person). Each function now has its own endpoint and matching controller. Converting tmdb results into a class has been alterted from using three classes; movie, show & person, and each have each their own convertTmdbTo function. Now the structure of the three types are more structured and no longer a single "seasoned" class object.
This commit is contained in:
45
seasoned_api/src/tmdb/convertTmdbToMovie.js
Normal file
45
seasoned_api/src/tmdb/convertTmdbToMovie.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const Movie = require('src/tmdb/types/movie');
|
||||
|
||||
const tmdbSwitcher = (tmdbMovie, property) => tmdbMovie[property]
|
||||
|
||||
function convertTmdbToMovie(tmdbMovie) {
|
||||
const movie = new Movie(tmdbMovie.id, tmdbMovie.title)
|
||||
movie.overview = tmdbMovie.overview;
|
||||
movie.rank = tmdbMovie.vote_average;
|
||||
|
||||
if (tmdbMovie.release_date !== undefined) {
|
||||
movie.release_date = new Date(tmdbMovie.release_date);
|
||||
movie.year = movie.release_date.getFullYear();
|
||||
}
|
||||
|
||||
if (tmdbMovie.poster_path !== undefined) {
|
||||
movie.poster = tmdbMovie.poster_path;
|
||||
}
|
||||
if (tmdbMovie.backdrop_path !== undefined) {
|
||||
movie.backdrop = tmdbMovie.backdrop_path;
|
||||
}
|
||||
|
||||
if (tmdbMovie.status !== undefined) {
|
||||
movie.status = tmdbMovie.status;
|
||||
}
|
||||
|
||||
if (tmdbMovie.genres !== undefined) {
|
||||
movie.genres = tmdbMovie.genres.map(genre => genre.name);
|
||||
}
|
||||
|
||||
if (tmdbMovie.tagline !== undefined) {
|
||||
movie.tagline = tmdbMovie.tagline;
|
||||
}
|
||||
|
||||
if (tmdbMovie.runtime !== undefined) {
|
||||
movie.runtime = tmdbMovie.runtime;
|
||||
}
|
||||
|
||||
if (tmdbMovie.imdb_id !== undefined) {
|
||||
movie.imdb_id = tmdbMovie.imdb_id;
|
||||
}
|
||||
|
||||
return movie;
|
||||
}
|
||||
|
||||
module.exports = convertTmdbToMovie;
|
||||
Reference in New Issue
Block a user