2022-04-02 12:00:24 +02:00
|
|
|
function getMovieUtils() {
|
|
|
|
let currentMovieList;
|
|
|
|
let currentFilter = 1337;
|
|
|
|
let url = "https://api.themoviedb.org/3/";
|
|
|
|
let api_key = "6c6af57a7dd83a4c720a50bb8f21853c";
|
|
|
|
|
|
|
|
let utils = {
|
|
|
|
getTopRatedMovies,
|
|
|
|
getPopularMovies,
|
|
|
|
getComingSoonMovies,
|
|
|
|
getNewMovies,
|
2022-04-03 01:58:58 +02:00
|
|
|
getCurrentFilter,
|
|
|
|
getGenres,
|
|
|
|
getMovieById
|
2022-04-02 12:00:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function getTopRatedMovies(page_index) {
|
2022-04-03 01:58:58 +02:00
|
|
|
return fetch(url + "movie/top_rated?api_key=" + api_key + "&page=" + page_index + "&language=fr")
|
2022-04-02 12:00:24 +02:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPopularMovies(page_index) {
|
2022-04-03 01:58:58 +02:00
|
|
|
return fetch(url + "movie/popular?api_key=" + api_key + "&page=" + page_index + "&language=fr")
|
2022-04-02 12:00:24 +02:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getComingSoonMovies(page_index) {
|
2022-04-03 01:58:58 +02:00
|
|
|
return fetch(url + "movie/upcoming?api_key=" + api_key + "&page=" + page_index + "&language=fr")
|
2022-04-02 12:00:24 +02:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNewMovies(page_index) {
|
2022-04-03 01:58:58 +02:00
|
|
|
return fetch(url + "movie/now_playing?api_key=" + api_key + "&page=" + page_index + "&language=fr")
|
2022-04-02 12:00:24 +02:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCurrentFilter() {
|
|
|
|
return localStorage.getItem("currfilter");
|
|
|
|
}
|
|
|
|
|
2022-04-03 01:58:58 +02:00
|
|
|
function getGenres() {
|
|
|
|
return fetch(url + "genre/movie/list?api_key=" + api_key + "&language=fr")
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => data)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMovieById(id) {
|
|
|
|
return fetch(url + "movie/" + id + "?api_key=" + api_key + "&language=fr")
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data=>data)
|
|
|
|
}
|
|
|
|
|
2022-04-02 12:00:24 +02:00
|
|
|
return utils;
|
|
|
|
}
|