diff --git a/api.php b/api.php index f9cd457..5ac8bb0 100644 --- a/api.php +++ b/api.php @@ -372,7 +372,7 @@ function fetchFromBlurayCom($ean) { static $lastRequest = 0; $empty = [ 'title' => '', 'year' => '', 'director' => '', 'actors' => '', - 'poster' => '', 'description' => '', 'length' => '', + 'poster' => '', 'description' => '', 'length' => '', 'publisher' => '', 'format' => 'Blu-ray', 'number_of_discs' => 1, 'aspect_ratio' => '' ]; @@ -394,9 +394,8 @@ function fetchFromBlurayCom($ean) { error_log("Blu-ray.com: 🔍 Recherche EAN $ean"); - // Recherche simple par EAN + // Recherche par EAN $searchUrl = "https://www.blu-ray.com/movies/search.php?ean=" . urlencode($ean) . "&action=search"; - $ch = curl_init($searchUrl); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, @@ -422,7 +421,7 @@ function fetchFromBlurayCom($ean) { return $empty; } - // Extraire l'URL du film + // Extraire l'URL du film - regex améliorée if (!preg_match('/href="(https:\/\/www\.blu-ray\.com\/movies\/[^"]+\/(\d+)\/)"/i', $searchHtml, $matches)) { error_log("Blu-ray.com: ❌ Film non trouvé pour EAN $ean"); return $empty; @@ -432,6 +431,9 @@ function fetchFromBlurayCom($ean) { $movieId = $matches[2]; error_log("Blu-ray.com: ✅ Film trouvé → $movieUrl"); + // Délai avant la 2ème requête + sleep(2); + // Récupérer la page du film $ch2 = curl_init($movieUrl); curl_setopt_array($ch2, [ @@ -455,28 +457,34 @@ function fetchFromBlurayCom($ean) { return $empty; } - // Extraction des données + // Extraction des données - regex améliorées + // Titre if (preg_match('/