From 7d234903d1c4e3c9d04c55f7b67e96cf700b003f Mon Sep 17 00:00:00 2001 From: Morgan Wattiez Date: Sun, 25 May 2025 02:32:08 +0200 Subject: [PATCH] filter films without description --- package-lock.json | 3 +-- public/index.html | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44f17e7..869b760 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,7 @@ "cheerio": "^1.0.0", "cors": "^2.8.5", "express": "^5.1.0" - }, - "devDependencies": {} + } }, "node_modules/accepts": { "version": "2.0.0", diff --git a/public/index.html b/public/index.html index c717b60..42b46e7 100644 --- a/public/index.html +++ b/public/index.html @@ -142,6 +142,23 @@ filmsDiv.innerHTML = '

No results. Try another query.

'; return; } + // Filtres sources inutiles (pas de description et/ou pas d'âge) + films = films.map(film => { + film.results = film.results.filter(r => { + // On considère valide si : + // - summary ou parentsNeedToKnow ou details.summary >= 8 chars + // - ET un âge existe (age, normalizedMarks, marks, details.ageLegal, etc) + let hasDescription = + (r.summary && r.summary.length >= 8) || + (r.parentsNeedToKnow && r.parentsNeedToKnow.length >= 8) || + (r.details && r.details.summary && r.details.summary.length >= 8); + let ages = getAllAges([r]); + let hasAge = ages && ages.length > 0; + return hasDescription && hasAge; + }); + return film; + }).filter(film => film.results.length > 0); + if (isFinite(maxAge)) { films = films.filter(film => { const uniqueResults = []; @@ -249,6 +266,7 @@ filmsDiv.innerHTML = `

Search failed. Check the console.

`; } } + document.getElementById('maxAge').addEventListener('input', function() { updateMaxAgeDisplay(); search();