Actualiser api.php

This commit is contained in:
2026-06-24 08:29:41 +02:00
parent 487cc74b77
commit 0370b797db
+19 -11
View File
@@ -235,8 +235,8 @@ function fetchTMDBFull($title, $year, $apiKey, $pdo) {
'poster' => !empty($details['poster_path']) ? "https://image.tmdb.org/t/p/w500" . $details['poster_path'] : '', 'poster' => !empty($details['poster_path']) ? "https://image.tmdb.org/t/p/w500" . $details['poster_path'] : '',
'length' => !empty($details['runtime']) ? $details['runtime'] . ' min' : '', 'length' => !empty($details['runtime']) ? $details['runtime'] . ' min' : '',
'streaming' => $streaming, 'streaming' => $streaming,
'overview' => $overview, // 🔥 NOUVEAU 'overview' => $overview,
'cast' => $cast // 🔥 NOUVEAU 'cast' => $cast
]; ];
setCache($pdo, $cacheKey, $result, 'tmdb'); setCache($pdo, $cacheKey, $result, 'tmdb');
@@ -293,9 +293,17 @@ switch ($action) {
break; break;
case 'get_films': case 'get_films':
$crit = $pdo->query("SELECT *, 'critique' AS type FROM critiques ORDER BY id DESC")->fetchAll(); // Fusion parfaite des deux tables avec des colonnes neutres (NULL) pour harmoniser le flux
$video = $pdo->query("SELECT *, 'videotheque' AS type FROM videotheque ORDER BY id DESC")->fetchAll(); $sql = "
echo json_encode(array_merge($crit, $video)); SELECT id, title, year, director, poster, rating, review, NULL AS description, streaming, 'critique' AS type
FROM critiques
UNION ALL
SELECT id, title, year, director, poster, NULL AS rating, NULL AS review, description, NULL AS streaming, 'videotheque' AS type
FROM videotheque
ORDER BY id DESC
";
$result = $pdo->query($sql)->fetchAll();
echo json_encode($result);
break; break;
case 'search_ean_full': case 'search_ean_full':
@@ -316,11 +324,10 @@ switch ($action) {
$result['format'] = $upcData['format']; $result['format'] = $upcData['format'];
} }
// 🔥 NOUVEAU : DVDFr pour remplacer l'affiche ET le synopsis lors d'un ajout manuel // 🔥 NOUVEAU : DVDFr pour remplacer l'affiche lors d'un ajout manuel
$dvdfrData = fetchDVDFr($ean, $pdo); $dvdfrCover = fetchDVDFr($ean, $pdo);
if (!empty($dvdfrData)) { if (!empty($dvdfrCover)) {
if (!empty($dvdfrData['poster'])) $result['poster'] = $dvdfrData['poster']; $result['poster'] = $dvdfrCover;
if (!empty($dvdfrData['synopsis'])) $result['description'] = $dvdfrData['synopsis'];
} }
$tmdbKey = getTmdbApiKey($pdo); $tmdbKey = getTmdbApiKey($pdo);
if ($tmdbKey && $tmdbQueryTitle) { if ($tmdbKey && $tmdbQueryTitle) {
@@ -427,7 +434,7 @@ switch ($action) {
$actors = implode(', ', array_slice($actorsArray, 0, 4)); $actors = implode(', ', array_slice($actorsArray, 0, 4));
} }
// 1. UPCitemDB // 1. UPCitemDB
if (!empty($ean)) { if (!empty($ean)) {
$upcData = fetchUPCitemdb($ean, $pdo); $upcData = fetchUPCitemdb($ean, $pdo);
if ($upcData) { if ($upcData) {
@@ -499,6 +506,7 @@ switch ($action) {
} }
} }
} }
}
// 🔥 L'INSERT SQL DOIT ÊTRE ICI (EN DEHORS DU IF TMDB) // 🔥 L'INSERT SQL DOIT ÊTRE ICI (EN DEHORS DU IF TMDB)
$sql = "INSERT INTO videotheque (id, title, year, director, poster, format, length, publisher, ean_isbn13, number_of_discs, aspect_ratio, description, actors) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE director=IF(VALUES(director)!='',VALUES(director),director), poster=IF(VALUES(poster)!='',VALUES(poster),poster), format=IF(VALUES(format)!='',VALUES(format),format), length=IF(VALUES(length)!='',VALUES(length),length), publisher=IF(VALUES(publisher)!='',VALUES(publisher),publisher), ean_isbn13=IF(VALUES(ean_isbn13)!='',VALUES(ean_isbn13),ean_isbn13), 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), description=IF(VALUES(description)!='',VALUES(description),description), actors=IF(VALUES(actors)!='',VALUES(actors),actors)"; $sql = "INSERT INTO videotheque (id, title, year, director, poster, format, length, publisher, ean_isbn13, number_of_discs, aspect_ratio, description, actors) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE director=IF(VALUES(director)!='',VALUES(director),director), poster=IF(VALUES(poster)!='',VALUES(poster),poster), format=IF(VALUES(format)!='',VALUES(format),format), length=IF(VALUES(length)!='',VALUES(length),length), publisher=IF(VALUES(publisher)!='',VALUES(publisher),publisher), ean_isbn13=IF(VALUES(ean_isbn13)!='',VALUES(ean_isbn13),ean_isbn13), 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), description=IF(VALUES(description)!='',VALUES(description),description), actors=IF(VALUES(actors)!='',VALUES(actors),actors)";
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);