diff --git a/api.php b/api.php
index 1dd5857..8e3a252 100644
--- a/api.php
+++ b/api.php
@@ -350,81 +350,107 @@ function fetchFromBlurayCom($ean) {
$ean = preg_replace('/[^0-9]/', '', (string)$ean);
if (strlen($ean) < 8) return $empty;
- // Recherche sur Blu-ray.com via l'EAN
- $searchUrl = "https://www.blu-ray.com/movies/search.php?ean=" . urlencode($ean) . "&action=search";
- $html = httpGet($searchUrl, 10, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');
+ // 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";
- if (!$html) return $empty;
+ // 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,
+ 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/' // Referer interne pour ne pas être bloqué
+ ]
+ ]);
+ $html = curl_exec($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
- // Extraire l'URL du film depuis les résultats de recherche
- if (preg_match('/]+href="(\/movies\/[^\/]+\/(\d+)\/)"[^>]*>\s*]+src="([^"]+)"[^>]*>/i', $html, $matches)) {
- $movieUrl = 'https://www.blu-ray.com' . $matches[1];
+ if (!$html || $httpCode !== 200) {
+ error_log("Blu-ray.com: ❌ Échec requête pour 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);
- // Récupérer la page du film pour plus de détails
- $movieHtml = httpGet($movieUrl, 10);
if ($movieHtml) {
- // Extraire le titre
- if (preg_match('/