Actualiser api.php

This commit is contained in:
2026-06-26 13:25:47 +02:00
parent 85d2c06d6f
commit 29c389a9a7
+15 -16
View File
@@ -122,26 +122,25 @@ function fetchCinemaPassion($title, $year = '', $ean = '', $pdo = null) {
$defaultPoster = 'assets/img/default_physical_media.jpg';
$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);
$searchRes = httpGet($searchUrl);
if ($searchRes) {
// Extraction du lien du premier résultat
if (preg_match('/<a href="(film-[^"]+\.html)"/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/' . $matches[1];
$filmRes = httpGet($filmUrl);
if ($searchRes && preg_match('/<a href="(film-[^"]+\.php)"/i', $searchRes, $matches)) {
$filmUrl = 'https://www.cinemapassion.com/film/' . $matches[1];
$filmRes = httpGet($filmUrl);
if ($filmRes) {
// Regex générique pour trouver l'image principale (souvent dans une balise img unique)
// Cherche le dossier "affiches" ou "posters"
if (preg_match('/src="(https?:\/\/[^"]+\/(?:affiches|posters)\/[^"]+\.(?:jpg|png))"/i', $filmRes, $imgMatches)) {
return [
'poster' => $imgMatches[1],
'title' => $cleanTitle,
'format' => 'Blu-ray'
];
}
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 (preg_match($pattern, $filmRes, $imgMatches)) {
return [
'poster' => $imgMatches[1],
'title' => $cleanTitle,
'format' => 'Blu-ray'
];
}
}
}