Actualiser api.php
This commit is contained in:
@@ -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'] : '',
|
||||
'length' => !empty($details['runtime']) ? $details['runtime'] . ' min' : '',
|
||||
'streaming' => $streaming,
|
||||
'overview' => $overview, // 🔥 NOUVEAU
|
||||
'cast' => $cast // 🔥 NOUVEAU
|
||||
'overview' => $overview,
|
||||
'cast' => $cast
|
||||
];
|
||||
|
||||
setCache($pdo, $cacheKey, $result, 'tmdb');
|
||||
@@ -293,9 +293,17 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'get_films':
|
||||
$crit = $pdo->query("SELECT *, 'critique' AS type FROM critiques ORDER BY id DESC")->fetchAll();
|
||||
$video = $pdo->query("SELECT *, 'videotheque' AS type FROM videotheque ORDER BY id DESC")->fetchAll();
|
||||
echo json_encode(array_merge($crit, $video));
|
||||
// Fusion parfaite des deux tables avec des colonnes neutres (NULL) pour harmoniser le flux
|
||||
$sql = "
|
||||
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;
|
||||
|
||||
case 'search_ean_full':
|
||||
@@ -316,11 +324,10 @@ switch ($action) {
|
||||
$result['format'] = $upcData['format'];
|
||||
}
|
||||
|
||||
// 🔥 NOUVEAU : DVDFr pour remplacer l'affiche ET le synopsis lors d'un ajout manuel
|
||||
$dvdfrData = fetchDVDFr($ean, $pdo);
|
||||
if (!empty($dvdfrData)) {
|
||||
if (!empty($dvdfrData['poster'])) $result['poster'] = $dvdfrData['poster'];
|
||||
if (!empty($dvdfrData['synopsis'])) $result['description'] = $dvdfrData['synopsis'];
|
||||
// 🔥 NOUVEAU : DVDFr pour remplacer l'affiche lors d'un ajout manuel
|
||||
$dvdfrCover = fetchDVDFr($ean, $pdo);
|
||||
if (!empty($dvdfrCover)) {
|
||||
$result['poster'] = $dvdfrCover;
|
||||
}
|
||||
$tmdbKey = getTmdbApiKey($pdo);
|
||||
if ($tmdbKey && $tmdbQueryTitle) {
|
||||
@@ -499,6 +506,7 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 🔥 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)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
Reference in New Issue
Block a user