Actualiser api.php
This commit is contained in:
@@ -357,44 +357,18 @@ switch ($action) {
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$id, $data['title'] ?? '', $data['year'] ?? '', $data['director'] ?? '', $data['poster'] ?? '', $data['rating'] ?? 3.0, $data['review'] ?? '', $streaming]);
|
||||
} else {
|
||||
// Récupérer les infos depuis BluRay.com et TMDB si poster vide
|
||||
// ── CORRECTION : Suppression de fetchBluRayPhysicalInfo qui n'existe pas ──
|
||||
if (empty($data['poster']) && !empty($data['title'])) {
|
||||
$bluRayData = fetchBluRayPhysicalInfo($data['ean_isbn13'] ?? '', $data['title'], $pdo);
|
||||
$tmdbData = fetchTmdbPosterAndSynopsis($data['title'], $data['year'] ?? '', $pdo);
|
||||
|
||||
// Fusionner les données
|
||||
if ($tmdbData['poster'] !== 'assets/img/default_physical_media.jpg') {
|
||||
$data['poster'] = $tmdbData['poster'];
|
||||
} elseif ($bluRayData['poster'] !== 'assets/img/default_physical_media.jpg') {
|
||||
$data['poster'] = $bluRayData['poster'];
|
||||
}
|
||||
|
||||
if (empty($data['description'])) {
|
||||
$data['description'] = $tmdbData['description'] ?: $bluRayData['description'];
|
||||
}
|
||||
if (empty($data['director'])) {
|
||||
$data['director'] = $tmdbData['director'];
|
||||
}
|
||||
if (empty($data['actors'])) {
|
||||
$data['actors'] = $tmdbData['actors'];
|
||||
}
|
||||
if (empty($data['length'])) {
|
||||
$data['length'] = $tmdbData['length'] ?: $bluRayData['length'];
|
||||
}
|
||||
if (empty($data['publisher'])) {
|
||||
$data['publisher'] = $bluRayData['publisher'];
|
||||
}
|
||||
if (empty($data['number_of_discs']) || $data['number_of_discs'] == 1) {
|
||||
if (!empty($bluRayData['number_of_discs'])) {
|
||||
$data['number_of_discs'] = $bluRayData['number_of_discs'];
|
||||
}
|
||||
}
|
||||
if (empty($data['aspect_ratio'])) {
|
||||
$data['aspect_ratio'] = $bluRayData['aspect_ratio'];
|
||||
}
|
||||
if (empty($data['format'])) {
|
||||
$data['format'] = $bluRayData['format'] ?: detectFormat($data['title'], $data['description'] ?? '');
|
||||
}
|
||||
if (empty($data['description'])) $data['description'] = $tmdbData['description'];
|
||||
if (empty($data['director'])) $data['director'] = $tmdbData['director'];
|
||||
if (empty($data['actors'])) $data['actors'] = $tmdbData['actors'];
|
||||
if (empty($data['length'])) $data['length'] = $tmdbData['length'];
|
||||
if (empty($data['format'])) $data['format'] = detectFormat($data['title'], $data['description'] ?? '');
|
||||
}
|
||||
|
||||
$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 title=VALUES(title), year=VALUES(year), 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)";
|
||||
|
||||
Reference in New Issue
Block a user