Actualiser api.php
This commit is contained in:
@@ -229,12 +229,19 @@ switch ($action) {
|
|||||||
$type = $data['type'] ?? 'critique';
|
$type = $data['type'] ?? 'critique';
|
||||||
$id = !empty($data['id']) ? $data['id'] : makeStableId($data['title'] ?? '', $data['year'] ?? '0000');
|
$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);
|
$apiKey = getTmdbApiKey($pdo);
|
||||||
$tmdbData = fetchTmdbData($data['title'] ?? '', $data['year'] ?? '', $apiKey);
|
$tmdbData = fetchTmdbData($data['title'] ?? '', $data['year'] ?? '', $apiKey);
|
||||||
if ($tmdbData) {
|
if ($tmdbData) {
|
||||||
if (empty($data['director'])) $data['director'] = $tmdbData['director'];
|
if (empty($data['director'])) $data['director'] = $tmdbData['director'];
|
||||||
if (empty($data['poster'])) $data['poster'] = $tmdbData['poster'];
|
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'] ?? '';
|
$director = $rowData['Director'] ?? $rowData['director'] ?? '';
|
||||||
$poster = $rowData['Poster'] ?? $rowData['poster'] ?? $rowData['image'] ?? '';
|
$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);
|
$tmdbData = fetchTmdbData($title, $year, $tmdbApiKey);
|
||||||
if ($tmdbData) {
|
if ($tmdbData) {
|
||||||
if (empty($director)) $director = $tmdbData['director'];
|
if (empty($director)) $director = $tmdbData['director'];
|
||||||
if (empty($poster)) $poster = $tmdbData['poster'];
|
if (empty($poster)) $poster = $tmdbData['poster'];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = makeStableId($title, $year);
|
$id = makeStableId($title, $year);
|
||||||
|
|||||||
Reference in New Issue
Block a user