Actualiser api.php
This commit is contained in:
@@ -281,10 +281,34 @@ function fetchPhysicalFromUpcmdb($ean, $pdo) {
|
||||
}
|
||||
|
||||
function fetchPhysicalByEan($ean, $pdo = null) {
|
||||
// 1. Essayer UPCitemdb
|
||||
// 1. Tenter UPCIndex en tout premier pour choper le vrai titre français
|
||||
$upcIndexTitle = fetchFromUpcIndex($ean);
|
||||
|
||||
if (!empty($upcIndexTitle)) {
|
||||
$res = emptyPhysicalResult();
|
||||
$res['title'] = $upcIndexTitle;
|
||||
$res['format'] = detectFormat($upcIndexTitle);
|
||||
|
||||
// Maintenant qu'on a un beau titre propre, on cherche sur MovieCovers
|
||||
$mc = fetchFromMovieCovers($upcIndexTitle, '');
|
||||
if (!empty($mc['poster'])) {
|
||||
$res['poster'] = $mc['poster'];
|
||||
}
|
||||
if (!empty($mc['director'])) {
|
||||
$res['director'] = $mc['director'];
|
||||
}
|
||||
if (!empty($mc['actors'])) {
|
||||
$res['actors'] = $mc['actors'];
|
||||
}
|
||||
if (!empty($mc['description'])) {
|
||||
$res['description'] = $mc['description'];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 2. Si UPCIndex échoue, essayer UPCitemdb (Fallback 1)
|
||||
$res = fetchPhysicalFromUpcitemdb($ean);
|
||||
if (!empty($res['title'])) {
|
||||
// 2. Chercher sur MovieCovers avec le titre trouvé
|
||||
$mc = fetchFromMovieCovers($res['title'], $res['year']);
|
||||
if (!empty($mc['poster'])) {
|
||||
$res['poster'] = $mc['poster'];
|
||||
@@ -301,7 +325,7 @@ function fetchPhysicalByEan($ean, $pdo = null) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 3. Fallback UPCMDB
|
||||
// 3. Dernier fallback : UPCMDB
|
||||
if ($pdo) {
|
||||
$fb = fetchPhysicalFromUpcmdb($ean, $pdo);
|
||||
if (!empty($fb['title'])) {
|
||||
@@ -313,7 +337,7 @@ function fetchPhysicalByEan($ean, $pdo = null) {
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
return $res ?? emptyPhysicalResult();
|
||||
}
|
||||
|
||||
// ── FONCTION POUR RÉCUPÉRER LES AFFICHES DEPUIS TMDB ──
|
||||
|
||||
Reference in New Issue
Block a user