Actualiser api.php
This commit is contained in:
@@ -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 <img id="largefrontimage" src="..._front.jpg">)
|
||||
if (preg_match('/src="(https:\/\/images\.static-bluray\.com\/movies\/covers\/\d+_front\.jpg[^"]*)"/i', $movieHtml, $m)) {
|
||||
$empty['poster'] = $m[1];
|
||||
} elseif (preg_match('/<img[^>]*class="coverfront"[^>]*src="([^"]+)"/i', $movieHtml, $m)) {
|
||||
if (preg_match('/<img[^>]*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('/<img[^>]*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 <div id="movie_info">)
|
||||
if (preg_match('/<div[^>]*id="movie_info"[^>]*>(.*?)<div[^>]*id="movie_review_intro"/is', $movieHtml, $infoBlock)) {
|
||||
|
||||
Reference in New Issue
Block a user