Actualiser api.php

This commit is contained in:
2026-06-26 13:28:30 +02:00
parent 29c389a9a7
commit 08cc9a1d70
+20 -14
View File
@@ -122,28 +122,34 @@ 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);
// URL de recherche (comme avant) // 1. Recherche
$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 && preg_match('/<a href="(film-[^"]+\.php)"/i', $searchRes, $matches)) { if ($searchRes) {
$filmUrl = 'https://www.cinemapassion.com/film/' . $matches[1]; // Recherche d'un lien contenant 'film-' et un chiffre
$filmRes = httpGet($filmUrl); if (preg_match('/href=["\'](\.\.\/film\/[^\'"]+-\d+\.php)["\']/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/' . ltrim($matches[1], './');
$filmRes = httpGet($filmUrl);
if ($filmRes) { if ($filmRes) {
// CORRECTION : On cible maintenant l'attribut src à l'intérieur du dossier covers3 // Regex améliorée : Cherche n'importe quel img src contenant 'covers'
// ou qui contient le titre du film dans le nom du fichier // sans se limiter à 'covers3' et accepte quotes simples ou doubles
$pattern = '/<img src=\'(http:\/\/www\.cinemapassion\.com\/covers_temp\/covers3\/[^\']+\.jpg)\'/i'; $pattern = '/src=["\'](http:\/\/www\.cinemapassion\.com\/covers_temp\/covers[^"\']+\.jpg)["\']/i';
if (preg_match($pattern, $filmRes, $imgMatches)) { if (preg_match($pattern, $filmRes, $imgMatches)) {
return [ return [
'poster' => $imgMatches[1], 'poster' => $imgMatches[1],
'title' => $cleanTitle, 'title' => $cleanTitle,
'format' => 'Blu-ray' 'format' => 'Blu-ray'
]; ];
}
} }
} }
} }
// Log si l'image n'est pas trouvée pour pouvoir debugger
error_log("CinemaPassion: Image non trouvée pour " . $cleanTitle);
return ['poster' => $defaultPoster, 'title' => $cleanTitle, 'format' => 'Blu-ray']; return ['poster' => $defaultPoster, 'title' => $cleanTitle, 'format' => 'Blu-ray'];
} }