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';
$cleanTitle = cleanTitle($title);
// URL de recherche (comme avant)
// 1. Recherche
$searchUrl = "https://www.cinemapassion.com/recherche.php?recherche=" . urlencode($cleanTitle);
$searchRes = httpGet($searchUrl);
if ($searchRes && preg_match('/<a href="(film-[^"]+\.php)"/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/film/' . $matches[1];
$filmRes = httpGet($filmUrl);
if ($searchRes) {
// Recherche d'un lien contenant 'film-' et un chiffre
if (preg_match('/href=["\'](\.\.\/film\/[^\'"]+-\d+\.php)["\']/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/' . ltrim($matches[1], './');
$filmRes = httpGet($filmUrl);
if ($filmRes) {
// CORRECTION : On cible maintenant l'attribut src à l'intérieur du dossier covers3
// ou qui contient le titre du film dans le nom du fichier
$pattern = '/<img src=\'(http:\/\/www\.cinemapassion\.com\/covers_temp\/covers3\/[^\']+\.jpg)\'/i';
if ($filmRes) {
// Regex améliorée : Cherche n'importe quel img src contenant 'covers'
// sans se limiter à 'covers3' et accepte quotes simples ou doubles
$pattern = '/src=["\'](http:\/\/www\.cinemapassion\.com\/covers_temp\/covers[^"\']+\.jpg)["\']/i';
if (preg_match($pattern, $filmRes, $imgMatches)) {
return [
'poster' => $imgMatches[1],
'title' => $cleanTitle,
'format' => 'Blu-ray'
];
if (preg_match($pattern, $filmRes, $imgMatches)) {
return [
'poster' => $imgMatches[1],
'title' => $cleanTitle,
'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'];
}