From 29adedb2b0c04e68f5e60913576eedb174362838 Mon Sep 17 00:00:00 2001 From: Cedric Date: Fri, 26 Jun 2026 13:41:36 +0200 Subject: [PATCH] Actualiser api.php --- api.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/api.php b/api.php index cec4b1d..b31e9f0 100644 --- a/api.php +++ b/api.php @@ -129,7 +129,7 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) { $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'; - // ── ÉTAPE 1 : Recherche via POST sur /moteur2.php (le vrai moteur du site) ── + // ── ÉTAPE 1 : Recherche via POST sur /moteur2.php ── $searchUrl = "https://www.cinemapassion.com/moteur2.php"; $ch = curl_init($searchUrl); @@ -158,11 +158,11 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) { if ($html) { // ── ÉTAPE 2 : Extraire le lien vers la page du film ── - // Pattern trouvé dans le HTML : href='../film/Saw-3814.php' + // Pattern : href='../film/Saw-3814.php' if (preg_match('/href=["\']([^"\']*film\/[^"\'\/]+-\d+\.php)["\']/i', $html, $matches)) { $filmPath = $matches[1]; - // Normaliser l'URL (supprimer les ../) + // Normaliser l'URL $filmPath = str_replace('../', '', $filmPath); if (strpos($filmPath, '/') !== 0) { $filmUrl = 'https://www.cinemapassion.com/' . $filmPath; @@ -178,13 +178,9 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) { // ── ÉTAPE 3 : Essayer plusieurs pages pour trouver l'image ── $pagesToTry = [ - // Page jaquette DVD (la plus probable) "https://www.cinemapassion.com/jaquette-dvd-{$filmName}-{$filmId}.php", - // Page jaquette Blu-ray "https://www.cinemapassion.com/jaquette-blu-ray-{$filmName}-{$filmId}.php", - // Page fiche complète du film $filmUrl, - // Page sticker "https://www.cinemapassion.com/sticker-dvd-{$filmName}-{$filmId}.php", ]; @@ -192,14 +188,13 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) { $pageRes = httpGet($pageUrl, 10, $userAgent); if ($pageRes) { - // Pattern pour l'image : src='http://www.cinemapassion.com/covers_temp/covers3/Saw-13005811062007.jpg' - // Accepte http ET https, covers avec ou sans chiffre (covers, covers2, covers3...) + // Pattern : src='http://www.cinemapassion.com/covers_temp/covers3/Saw-13005811062007.jpg' $imgPattern = '/src=["\']?(https?:\/\/www\.cinemapassion\.com\/covers_temp\/covers\d*\/[^"\'\s>]+\.jpg)["\']?/i'; if (preg_match($imgPattern, $pageRes, $imgMatches)) { $posterUrl = $imgMatches[1]; - // Forcer HTTPS pour éviter les mixed content + // Forcer HTTPS $posterUrl = str_replace('http://', 'https://', $posterUrl); error_log("CinemaPassion: Image trouvée pour '{$cleanTitle}' → {$posterUrl}"); @@ -215,7 +210,7 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) { } } - // ── FALLBACK : Chercher directement une image covers_temp dans les résultats ── + // ── FALLBACK : Chercher directement une image dans les résultats ── $imgPattern = '/src=["\']?(https?:\/\/www\.cinemapassion\.com\/covers_temp\/covers\d*\/[^"\'\s>]+\.jpg)["\']?/i'; if (preg_match($imgPattern, $html, $imgMatches)) { $posterUrl = str_replace('http://', 'https://', $imgMatches[1]);