Actualiser api.php
This commit is contained in:
@@ -221,10 +221,22 @@ switch ($action) {
|
|||||||
$rating = ($ratingRaw !== '' && $ratingRaw !== null) ? (float)$ratingRaw : null;
|
$rating = ($ratingRaw !== '' && $ratingRaw !== null) ? (float)$ratingRaw : null;
|
||||||
$review = $rowData['Review'] ?? $rowData['review'] ?? '';
|
$review = $rowData['Review'] ?? $rowData['review'] ?? '';
|
||||||
$director = ''; $poster = ''; $streaming = '';
|
$director = ''; $poster = ''; $streaming = '';
|
||||||
|
|
||||||
if ($tmdbApiKey && !empty($title)) {
|
if ($tmdbApiKey && !empty($title)) {
|
||||||
$tmdbData = fetchTMDBFull($title, $year, $tmdbApiKey, $pdo);
|
$tmdbData = fetchTMDBFull($title, $year, $tmdbApiKey, $pdo);
|
||||||
if ($tmdbData) { $director = $tmdbData['director']; $poster = $tmdbData['poster']; $streaming = $tmdbData['streaming']; if(empty($year)) $year = $tmdbData['year']; }
|
if ($tmdbData) {
|
||||||
|
$director = $tmdbData['director'];
|
||||||
|
$poster = $tmdbData['poster'];
|
||||||
|
$streaming = $tmdbData['streaming'];
|
||||||
|
if(empty($year)) $year = $tmdbData['year'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔥 CORRECTION : Si le streaming est vide après TMDB, on met la valeur par défaut
|
||||||
|
if (empty($streaming)) {
|
||||||
|
$streaming = 'Support physique / Cinéma';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO critiques (id, title, year, director, poster, rating, review, streaming) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE rating=VALUES(rating), review=IF(VALUES(review)!='',VALUES(review),review), director=IF(VALUES(director)!='',VALUES(director),director), poster=IF(VALUES(poster)!='',VALUES(poster),poster), streaming=IF(VALUES(streaming)!='',VALUES(streaming),streaming)";
|
$sql = "INSERT INTO critiques (id, title, year, director, poster, rating, review, streaming) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE rating=VALUES(rating), review=IF(VALUES(review)!='',VALUES(review),review), director=IF(VALUES(director)!='',VALUES(director),director), poster=IF(VALUES(poster)!='',VALUES(poster),poster), streaming=IF(VALUES(streaming)!='',VALUES(streaming),streaming)";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute([$id, $title, $year, $director, $poster, $rating, $review, $streaming]);
|
$stmt->execute([$id, $title, $year, $director, $poster, $rating, $review, $streaming]);
|
||||||
|
|||||||
Reference in New Issue
Block a user