diff --git a/api.php b/api.php
index 6928a57..26fd310 100644
--- a/api.php
+++ b/api.php
@@ -350,10 +350,9 @@ function fetchFromBlurayCom($ean) {
$ean = preg_replace('/[^0-9]/', '', (string)$ean);
if (strlen($ean) < 8) return $empty;
- // 1. Recherche sur Blu-ray.com via l'EAN (URL exacte extraite du site)
- $searchUrl = "https://www.blu-ray.com/movies/search.php?ean=" . urlencode($ean) . "&action=search&submit=Search";
+ // ÉTAPE 1 : Recherche par EAN sur Blu-ray.com
+ $searchUrl = "https://www.blu-ray.com/movies/search.php?ean=" . urlencode($ean) . "&action=search";
- // Requête CURL directe pour éviter les blocages (Referer cinemapassion.com bloqué par Blu-ray.com)
$ch = curl_init($searchUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
@@ -365,94 +364,135 @@ function fetchFromBlurayCom($ean) {
CURLOPT_HTTPHEADER => [
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
- 'Referer: https://www.blu-ray.com/' // Referer interne pour ne pas être bloqué
+ 'Referer: https://www.blu-ray.com/'
]
]);
- $html = curl_exec($ch);
+ $searchHtml = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
- if (!$html || $httpCode !== 200) {
- error_log("Blu-ray.com: ❌ Échec requête pour EAN $ean (HTTP $httpCode)");
+ if (!$searchHtml || $httpCode !== 200) {
+ error_log("Blu-ray.com: ❌ Échec recherche EAN $ean (HTTP $httpCode)");
return $empty;
}
- // 2. Extraction des résultats (Correction du Regex pour matcher l'URL absolue)
- // Structure réelle :
- if (preg_match('/href="(https?:\/\/www\.blu-ray\.com\/movies\/[^\/]+\/(\d+)\/)"[^>]*>.*?
]+class="cover"[^>]+src="([^"]+)"/is', $html, $matches)) {
- $movieUrl = $matches[1];
- $movieId = $matches[2];
- $posterUrl = $matches[3];
-
- // Convertir l'affiche en haute résolution
- $posterUrl = str_replace('_small.jpg', '_large.jpg', $posterUrl);
- $posterUrl = str_replace('_medium.jpg', '_large.jpg', $posterUrl);
- $empty['poster'] = $posterUrl;
-
- // 3. Récupérer la page du film pour les détails techniques
- $ch2 = curl_init($movieUrl);
- curl_setopt_array($ch2, [
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_TIMEOUT => 15,
- CURLOPT_CONNECTTIMEOUT => 5,
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
- CURLOPT_HTTPHEADER => [
- 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
- 'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
- 'Referer: https://www.blu-ray.com/'
- ]
- ]);
- $movieHtml = curl_exec($ch2);
- curl_close($ch2);
-
- if ($movieHtml) {
- // Titre
- if (preg_match('/
)
+ if (preg_match('/src="(https:\/\/images\.static-bluray\.com\/movies\/covers\/\d+_front\.jpg[^"]*)"/i', $movieHtml, $m)) {
+ $empty['poster'] = $m[1];
+ } elseif (preg_match('/