Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LuisED18/proyecto-pagina-peliculas/llms.txt

Use this file to discover all available pages before exploring further.

By the end of this guide you will have a fully working local copy of Pelisgo running in your browser. You’ll clone the repository, obtain a free TMDB API key, drop it into the one place it belongs in the code, and open the app — all in under five minutes. No package managers, no build commands, and no prior backend knowledge required.
1

Clone the repository

Clone the project from GitHub to your local machine. The repository contains everything the app needs — there is nothing to install afterwards.
git clone https://github.com/LuisED18/proyecto-pagina-peliculas.git
cd proyecto-pagina-peliculas
2

Get a TMDB API key

Pelisgo fetches all movie and series data from The Movie Database (TMDB). You need a free API key to make those requests.
  1. Go to themoviedb.org and create a free account.
  2. After logging in, click your avatar in the top-right corner and choose Settings.
  3. In the left sidebar, select API.
  4. Under API Key (v3 auth), click Create if you haven’t already, fill in the short form (choose Developer and describe any personal project), and submit.
  5. Copy the long alphanumeric string shown as API Key (v3 auth) — that is the value you will paste in the next step.
3

Add your API key

Open js/main.js in any text editor. The very first line declares the API key constant:
const API_KEY = '62d0e228965166bf48326dcfc99023d3';
Replace the placeholder value with your own key:
const API_KEY = 'YOUR_TMDB_V3_API_KEY_HERE';
The two lines below it set the base URLs and do not need to change:
const BASE_URL = 'https://api.themoviedb.org/3';
const IMAGE_BASE_URL = 'https://image.tmdb.org/t/p/w500';
Save the file. That is the only configuration change required.
4

Serve the project

Because Pelisgo is pure static HTML, you can open it directly from the filesystem or through any static server. Pick whichever method suits you:
# Open the movies page straight from disk
open index.html
On Windows you can double-click index.html in File Explorer to open it in your default browser.
Some browsers block fetch() requests when a page is loaded via the file:// protocol. If you see no results when opening index.html directly, use the Python or Node server option instead so the page is served over http://localhost.
5

Browse the app

With the app open in your browser, you’re ready to explore:
  • Movies page (index.html) — loads automatically on start and displays the current TMDB popular movies grid. Each card shows the poster, title, and release year.
  • Series page (series.html) — click Series in the navigation bar to switch to the TV series catalogue. The same card grid re-renders with TV show data.
  • Search — type any movie or series title in the blueviolet search bar in the top-right of the navbar. Results update live after you’ve typed at least three characters. Clear the field to return to the popular list.
  • Genres dropdown — hover over Generos in the nav to see the genre list. Genre filtering is currently in progress and will be wired to TMDB’s genre endpoints in a future update.

Full Source: js/main.js

The complete JavaScript module that powers both pages is short enough to read in one sitting:
const API_KEY = '62d0e228965166bf48326dcfc99023d3';
const BASE_URL = 'https://api.themoviedb.org/3';
const IMAGE_BASE_URL = 'https://image.tmdb.org/t/p/w500';

const seccionContenido = document.querySelector('.seccionPeliculas');
const buscador = document.getElementById('Buscador');

// DETECCIÓN: ¿Estamos en series.html o index.html?
// Esto busca la palabra "series" en la URL de tu navegador
const esPaginaSeries = window.location.pathname.includes('series');
const tipo = esPaginaSeries ? 'tv' : 'movie';

// 1. Obtener Datos (Dinámico: Películas o Series)
async function obtenerContenido(query = '') {
    try {
        let endpoint;
        if (query) {
            // Buscador
            endpoint = `${BASE_URL}/search/${tipo}?api_key=${API_KEY}&language=es-ES&query=${query}`;
        } else {
            // Populares (Pelis o Series)
            endpoint = `${BASE_URL}/${tipo}/popular?api_key=${API_KEY}&language=es-ES&page=1`;
        }

        const respuesta = await fetch(endpoint);
        const datos = await respuesta.json();
        
        if (datos.results) {
            mostrarCards(datos.results);
        }
    } catch (error) {
        console.error('Error al obtener los datos:', error);
    }
}

// 2. Mostrar en el HTML
function mostrarCards(items) {
    seccionContenido.innerHTML = ''; 
    
    items.forEach(item => {
        // Validación de datos según el tipo (Pelicula vs Serie)
        const titulo = esPaginaSeries ? item.name : item.title;
        const fechaOriginal = esPaginaSeries ? item.first_air_date : item.release_date;
        const año = fechaOriginal ? fechaOriginal.split('-')[0] : 'S/N';

        const poster = item.poster_path 
            ? IMAGE_BASE_URL + item.poster_path 
            : 'https://via.placeholder.com/500x750?text=Sin+Imagen';

        const card = document.createElement('div');
        card.classList.add('card');

        card.innerHTML = `
            <img src="${poster}" alt="${titulo}">
            <div class="info">
                <h3 class="tituloPeli">${titulo}</h3>
                <span class="fecha">${año}</span>
            </div>
        `;
        seccionContenido.appendChild(card);
    });
}

// 3. Evento de Búsqueda (Se adapta automáticamente)
if (buscador) {
    buscador.addEventListener('keyup', (e) => {
        if (e.target.value.length > 2) {
            obtenerContenido(e.target.value);
        } else if (e.target.value === "") {
            obtenerContenido();
        }
    });
}

// Inicio
obtenerContenido();
Never commit your real TMDB API key to a public repository. Add a .env file or use a secrets manager if you plan to deploy or share your fork. At a minimum, add your key file to .gitignore before your first commit.
TMDB free-tier API keys are subject to rate limits (roughly 40 requests per 10 seconds). Rapid successive searches or bulk page loads may result in 429 Too Many Requests responses. If you hit the limit, wait a few seconds and try again. For production use, consider caching responses or upgrading to a TMDB Pro account.

Build docs developers (and LLMs) love