Repository: felipeAguiarCode/netflix-clone-2.0
Branch: main
Commit: c53339782bcb
Files: 10
Total size: 6.8 KB
Directory structure:
gitextract_vzoler65/
├── .gitignore
├── package.json
├── public/
│ ├── index.html
│ ├── scripts/
│ │ ├── api.js
│ │ ├── home.js
│ │ └── scroll.js
│ └── styles/
│ ├── reset.css
│ └── style.css
└── src/
├── app.js
└── server.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
node_modules/
================================================
FILE: package.json
================================================
{
"name": "netflix-clone-3.0",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}
================================================
FILE: public/index.html
================================================
Filmes
Filmes para assistir com toda a familia
================================================
FILE: public/scripts/api.js
================================================
const api_key = "d19a1946970f98fae002af7545322879"
const img_url = "https://image.tmdb.org/t/p/w500"
const genres_list_http = "https://api.themoviedb.org/3/genre/movie/list?"
const movie_genres_http = "https://api.themoviedb.org/3/discover/movie?"
================================================
FILE: public/scripts/home.js
================================================
const main = document.querySelector(".main")
fetchGenresList()
function fetchGenresList() {
const url = genres_list_http + new URLSearchParams({
api_key: api_key
})
fetch(url)
.then(res => res.json())
.then(data => {
data.genres.forEach(item => {
fetchMoviesListByGenres(item.id, item.name)
});
})
.catch(err => console.log(err))
}
const fetchMoviesListByGenres = (id, genres) => {
const url = movie_genres_http + new URLSearchParams({
api_key: api_key,
with_genres: id,
page: Math.floor(Math.random() * 3) + 1
})
fetch(url)
.then(res => res.json())
.then(data => {
const category = genres.replace("_", " ")
makeCategoryElement(category, data.results)
})
.catch(err => console.log(err))
}
const makeCategoryElement = (category, data) => {
const categoryHTML = `