Actualiser api.php
This commit is contained in:
@@ -171,7 +171,8 @@ function fetchPhysicalFromUpcitemdb($ean) {
|
|||||||
'length' => ''
|
'length' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
unction fetchPhysicalFromUpcmdb($ean, $pdo) {
|
|
||||||
|
function fetchPhysicalFromUpcmdb($ean, $pdo) {
|
||||||
$empty = ['title'=>'','publisher'=>'','format'=>'','length'=>'','number_of_discs'=>1,'aspect_ratio'=>'','year'=>''];
|
$empty = ['title'=>'','publisher'=>'','format'=>'','length'=>'','number_of_discs'=>1,'aspect_ratio'=>'','year'=>''];
|
||||||
$apiKey = getUpcmdbApiKey($pdo);
|
$apiKey = getUpcmdbApiKey($pdo);
|
||||||
if (!$apiKey) return $empty;
|
if (!$apiKey) return $empty;
|
||||||
@@ -199,7 +200,6 @@ unction fetchPhysicalFromUpcmdb($ean, $pdo) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fetchPhysicalByEan($ean, $pdo = null) {
|
function fetchPhysicalByEan($ean, $pdo = null) {
|
||||||
$res = fetchPhysicalFromUpcitemdb($ean);
|
$res = fetchPhysicalFromUpcitemdb($ean);
|
||||||
if (!empty($res['title'])) return $res;
|
if (!empty($res['title'])) return $res;
|
||||||
@@ -403,7 +403,8 @@ case 'save_config':
|
|||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
";
|
";
|
||||||
$result = $pdo->query($sql)->fetchAll();
|
$result = $pdo->query($sql)->fetchAll();
|
||||||
foreach ($result as $row) {
|
// IMPORTANT : Utilisation du pointeur `&` pour que la modification soit effective dans $result
|
||||||
|
foreach ($result as &$row) {
|
||||||
if ($row['rating'] !== null) {
|
if ($row['rating'] !== null) {
|
||||||
$ratingVal = (float)$row['rating'];
|
$ratingVal = (float)$row['rating'];
|
||||||
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
||||||
@@ -432,7 +433,7 @@ case 'save_config':
|
|||||||
$sql = "INSERT INTO critiques (id, title, year, director, poster, rating, review, streaming) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title=VALUES(title), year=VALUES(year), director=VALUES(director), poster=VALUES(poster), rating=VALUES(rating), review=VALUES(review), streaming=VALUES(streaming)";
|
$sql = "INSERT INTO critiques (id, title, year, director, poster, rating, review, streaming) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title=VALUES(title), year=VALUES(year), director=VALUES(director), poster=VALUES(poster), rating=VALUES(rating), review=VALUES(review), streaming=VALUES(streaming)";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute([$id, $data['title'] ?? '', $data['year'] ?? '', $data['director'] ?? '', $data['poster'] ?? '', $data['rating'] ?? 3.0, $data['review'] ?? '', $streaming]);
|
$stmt->execute([$id, $data['title'] ?? '', $data['year'] ?? '', $data['director'] ?? '', $data['poster'] ?? '', $data['rating'] ?? 3.0, $data['review'] ?? '', $streaming]);
|
||||||
} else {
|
} else {
|
||||||
// ── CORRECTION : Suppression de fetchBluRayPhysicalInfo qui n'existe pas ──
|
// ── CORRECTION : Suppression de fetchBluRayPhysicalInfo qui n'existe pas ──
|
||||||
if (empty($data['poster']) && !empty($data['title'])) {
|
if (empty($data['poster']) && !empty($data['title'])) {
|
||||||
$tmdbData = fetchTmdbPosterAndSynopsis($data['title'], $data['year'] ?? '', $pdo);
|
$tmdbData = fetchTmdbPosterAndSynopsis($data['title'], $data['year'] ?? '', $pdo);
|
||||||
@@ -554,4 +555,3 @@ case 'import_batch':
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user