Actualiser api.php

This commit is contained in:
2026-06-26 13:25:47 +02:00
parent 85d2c06d6f
commit 29c389a9a7
+8 -9
View File
@@ -122,20 +122,20 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) {
$defaultPoster = 'assets/img/default_physical_media.jpg'; $defaultPoster = 'assets/img/default_physical_media.jpg';
$cleanTitle = cleanTitle($title); $cleanTitle = cleanTitle($title);
// ÉTAPE 1 : URL de recherche standardisée // URL de recherche (comme avant)
$searchUrl = "https://www.cinemapassion.com/recherche.php?recherche=" . urlencode($cleanTitle); $searchUrl = "https://www.cinemapassion.com/recherche.php?recherche=" . urlencode($cleanTitle);
$searchRes = httpGet($searchUrl); $searchRes = httpGet($searchUrl);
if ($searchRes) { if ($searchRes && preg_match('/<a href="(film-[^"]+\.php)"/i', $searchRes, $matches)) {
// Extraction du lien du premier résultat $filmUrl = 'https://www.cinemapassion.com/film/' . $matches[1];
if (preg_match('/<a href="(film-[^"]+\.html)"/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/' . $matches[1];
$filmRes = httpGet($filmUrl); $filmRes = httpGet($filmUrl);
if ($filmRes) { if ($filmRes) {
// Regex générique pour trouver l'image principale (souvent dans une balise img unique) // CORRECTION : On cible maintenant l'attribut src à l'intérieur du dossier covers3
// Cherche le dossier "affiches" ou "posters" // ou qui contient le titre du film dans le nom du fichier
if (preg_match('/src="(https?:\/\/[^"]+\/(?:affiches|posters)\/[^"]+\.(?:jpg|png))"/i', $filmRes, $imgMatches)) { $pattern = '/<img src=\'(http:\/\/www\.cinemapassion\.com\/covers_temp\/covers3\/[^\']+\.jpg)\'/i';
if (preg_match($pattern, $filmRes, $imgMatches)) {
return [ return [
'poster' => $imgMatches[1], 'poster' => $imgMatches[1],
'title' => $cleanTitle, 'title' => $cleanTitle,
@@ -144,7 +144,6 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) {
} }
} }
} }
}
return ['poster' => $defaultPoster, 'title' => $cleanTitle, 'format' => 'Blu-ray']; return ['poster' => $defaultPoster, 'title' => $cleanTitle, 'format' => 'Blu-ray'];
} }