diff --git a/api.php b/api.php index 2204e1a..16cd1ea 100644 --- a/api.php +++ b/api.php @@ -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,12 +322,11 @@ switch ($action) { $director = $rowData['Director'] ?? $rowData['director'] ?? ''; $poster = $rowData['Poster'] ?? $rowData['poster'] ?? $rowData['image'] ?? ''; - if (empty($director) || empty($poster)) { - $tmdbData = fetchTmdbData($title, $year, $tmdbApiKey); - if ($tmdbData) { - if (empty($director)) $director = $tmdbData['director']; - if (empty($poster)) $poster = $tmdbData['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);