Actualiser api.php
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user