BE tmdb service: fetchMovieData support for tv series
This commit is contained in:
1 parent
f964562cb2
commit
f0970a07e8
1 file changed
+11
-5
@@ -41,9 +41,10 @@ const tmdb_apiKey = "5323ef3dc430df54dcb9e58c37fd22bb";
|
||||
// }
|
||||
|
||||
|
||||
async function fetchMovieData(tmdb_id) {
|
||||
async function fetchEntryData(tmdb_id, is_tvserie) {
|
||||
// fetching the informations
|
||||
let url = `https://api.themoviedb.org/3/movie/${tmdb_id}?api_key=${tmdb_apiKey}&language=en-US`
|
||||
let type = is_tvserie ? "tv" : "movie";
|
||||
let url = `https://api.themoviedb.org/3/${type}/${tmdb_id}?api_key=${tmdb_apiKey}&language=en-US`
|
||||
let data;
|
||||
await axios.get(url)
|
||||
.then((response) => {
|
||||
@@ -51,9 +52,14 @@ async function fetchMovieData(tmdb_id) {
|
||||
data = response.data;
|
||||
})
|
||||
|
||||
const savedMovie = await saveEntry(data, true);
|
||||
let savedEntry;
|
||||
|
||||
return savedMovie.get({ plain: true });
|
||||
if (is_tvserie)
|
||||
savedEntry = await saveEntry(data);
|
||||
else
|
||||
savedEntry = await saveEntry(data);
|
||||
|
||||
return savedEntry.get({ plain: true });
|
||||
}
|
||||
|
||||
// async function fetchSerieData(serieId) {
|
||||
@@ -176,7 +182,7 @@ async function fetchMovieData(tmdb_id) {
|
||||
module.exports = {
|
||||
// getMovies,
|
||||
|
||||
fetchMovieData,
|
||||
fetchEntryData,
|
||||
// fetchSerieData,
|
||||
|
||||
// insertMovieSerie,
|
||||
|
||||
Reference in new issue
Block a user