From 3d3fdc671a120831619bdcba4739e4318e5fd459 Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 30 Jun 2026 13:50:05 +0200 Subject: [PATCH] Actualiser api.php --- api.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/api.php b/api.php index 8bdcbc4..dc02668 100644 --- a/api.php +++ b/api.php @@ -653,15 +653,25 @@ case 'import_batch': $pdo->beginTransaction(); $imported = 0; $skipped = 0; try { - if ($type === 'videotheque') { + if ($type === 'videotheque') { $stmt = $pdo->prepare("INSERT INTO videotheque (id, title, year, format, poster, ean_isbn13, description, length, number_of_discs, aspect_ratio, actors, publisher, director) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE - title=VALUES(title), year=VALUES(year), format=VALUES(format), poster=VALUES(poster), ean_isbn13=VALUES(ean_isbn13), description=VALUES(description), length=VALUES(length), number_of_discs=VALUES(number_of_discs), aspect_ratio=VALUES(aspect_ratio), actors=VALUES(actors), publisher=VALUES(publisher), director=VALUES(director)"); + title=VALUES(title), year=VALUES(year), format=VALUES(format), + poster=IF(VALUES(poster)!='assets/img/default_physical_media.jpg', VALUES(poster), poster), + ean_isbn13=IF(VALUES(ean_isbn13)!='', VALUES(ean_isbn13), ean_isbn13), + description=IF(VALUES(description)!='', VALUES(description), description), + length=IF(VALUES(length)!='', VALUES(length), length), + number_of_discs=IF(VALUES(number_of_discs)!=1, VALUES(number_of_discs), number_of_discs), + aspect_ratio=IF(VALUES(aspect_ratio)!='', VALUES(aspect_ratio), aspect_ratio), + actors=IF(VALUES(actors)!='', VALUES(actors), actors), + publisher=IF(VALUES(publisher)!='', VALUES(publisher), publisher), + director=IF(VALUES(director)!='', VALUES(director), director)"); foreach ($items as $item) { $ean = preg_replace('/[^0-9]/', '', (string)($item['ean'] ?? '')); - $csvTitle = trim($item['title'] ?? ''); // Titre issu du CSV (fallback) + $csvTitle = trim($item['title'] ?? ''); // ✅ Titre issu du CSV (fallback) + // ✅ On ne skip que si on n'a ni EAN ni titre if (strlen($ean) < 8 && empty($csvTitle)) { $skipped++; continue; @@ -670,9 +680,10 @@ case 'import_batch': // 1. Données physiques via BLU-RAY.COM (prioritaire) $blurayData = !empty($ean) ? fetchFromBlurayCom($ean) : []; - // Si Blu-ray.com trouve le film, on prend ses données. Sinon, on utilise le titre du CSV. + // ✅ Si Blu-ray.com trouve le film, on prend son titre. Sinon, on prend celui du CSV. $title = !empty($blurayData['title']) ? $blurayData['title'] : $csvTitle; + // ✅ Si toujours pas de titre, on skip if (empty($title)) { $skipped++; continue; @@ -689,8 +700,8 @@ case 'import_batch': $director = $blurayData['director'] ?? ''; $actors = $blurayData['actors'] ?? ''; - // 2. Fallback TMDB si Blu-ray.com n'a pas trouvé certaines données - if (empty($poster) || empty($director) || empty($actors) || empty($desc)) { + // 2. ✅ FALLBACK TMDB si Blu-ray.com n'a pas trouvé certaines données + if (empty($poster) || empty($director) || empty($actors) || empty($desc) || empty($year)) { $tmdb = fetchTmdbPosterAndSynopsis($title, $year, $pdo); if (empty($poster) || $poster === 'assets/img/default_physical_media.jpg') {