Actualiser api.php

This commit is contained in:
2026-06-19 14:44:09 +02:00
parent 80c98dda1c
commit 907bf10cf5
+9 -3
View File
@@ -229,12 +229,19 @@ switch ($action) {
$type = $data['type'] ?? 'critique';
$id = !empty($data['id']) ? $data['id'] : makeStableId($data['title'] ?? '', $data['year'] ?? '0000');
if (empty($data['director']) || empty($data['poster'])) {
if (empty($data['director']) || empty($data['poster']) || empty($data['streaming'])) {
$apiKey = getTmdbApiKey($pdo);
$tmdbData = fetchTmdbData($data['title'] ?? '', $data['year'] ?? '', $apiKey);
if ($tmdbData) {
if (empty($data['director'])) $data['director'] = $tmdbData['director'];
if (empty($data['poster'])) $data['poster'] = $tmdbData['poster'];
if (empty($data['streaming'])) {
$data['streaming'] = !empty($tmdbData['streaming'])
? $tmdbData['streaming']
: 'Disponible en support physique ou Cinéma';
}
} elseif (empty($data['streaming'])) {
$data['streaming'] = 'Disponible en support physique ou Cinéma';
}
}
@@ -315,13 +322,12 @@ switch ($action) {
$director = $rowData['Director'] ?? $rowData['director'] ?? '';
$poster = $rowData['Poster'] ?? $rowData['poster'] ?? $rowData['image'] ?? '';
if (empty($director) || empty($poster)) {
// 🔍 RÉCUPÉRATION AUTO TMDB (toujours appelé pour récupérer le streaming)
$tmdbData = fetchTmdbData($title, $year, $tmdbApiKey);
if ($tmdbData) {
if (empty($director)) $director = $tmdbData['director'];
if (empty($poster)) $poster = $tmdbData['poster'];
}
}
$id = makeStableId($title, $year);