diff --git a/api.php b/api.php
index dc02668..4d4924f 100644
--- a/api.php
+++ b/api.php
@@ -340,7 +340,10 @@ function fetchTmdbPosterAndSynopsis($title, $year = '', $pdo = null) {
// ── FONCTION POUR RÉCUPÉRER LES DONNÉES DEPUIS BLU-RAY.COM ──
function fetchFromBlurayCom($ean) {
- static $lastRequest = 0;
+ static $lastRequest = null;
+ if ($lastRequest === null) {
+ $lastRequest = microtime(true);
+ }
$empty = [
'title' => '', 'year' => '', 'director' => '', 'actors' => '',
'poster' => '', 'description' => '', 'length' => '',
@@ -353,8 +356,8 @@ function fetchFromBlurayCom($ean) {
// ✅ THROTTLE : Attendre 3 secondes entre chaque requête pour éviter le blocage
$now = microtime(true);
- if ($lastRequest > 0 && ($now - $lastRequest) < 3) {
- usleep((int)(3 - ($now - $lastRequest)) * 1000000);
+ if ($lastRequest > 0 && ($now - $lastRequest) < 1.5) {
+ usleep((int)((1.5 - ($now - $lastRequest)) * 1000000));
}
$lastRequest = microtime(true);
@@ -473,13 +476,16 @@ function fetchFromBlurayCom($ean) {
}
// Affiche HD (depuis
)
- if (preg_match('/src="(https:\/\/images\.static-bluray\.com\/movies\/covers\/\d+_front\.jpg[^"]*)"/i', $movieHtml, $m)) {
- $empty['poster'] = $m[1];
- } elseif (preg_match('/]*class="coverfront"[^>]*src="([^"]+)"/i', $movieHtml, $m)) {
+ if (preg_match('/
]*class="coverfront"[^>]*src="([^"]+)"/i', $movieHtml, $m)) {
$posterUrl = $m[1];
+ // Convertir _large.jpg en _front.jpg pour meilleure qualité
$posterUrl = preg_replace('/_large\.jpg/', '_front.jpg', $posterUrl);
$empty['poster'] = $posterUrl;
- }
+ } elseif (preg_match('/
]*class="coverfront"[^>]*src="([^"]+)"/i', $movieHtml, $m)) {
+ $posterUrl = $m[1];
+ $posterUrl = preg_replace('/_large\.jpg/', '_front.jpg', $posterUrl);
+ $empty['poster'] = $posterUrl;
+ }
// Synopsis, Réalisateur, Acteurs (depuis