Actualiser api.php
This commit is contained in:
@@ -473,7 +473,7 @@ function fetchFromMovieCovers($title, $year = '') {
|
|||||||
return $empty;
|
return $empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── AGGREGATEUR PHYSIQUE (VERSION MODIFIÉE AVEC GO-UPC ET UPCINDEX) ──
|
// Dans la fonction fetchPhysicalByEan - Ligne ~780
|
||||||
function fetchPhysicalByEan($ean, $pdo = null) {
|
function fetchPhysicalByEan($ean, $pdo = null) {
|
||||||
error_log("=== DEBUT fetchPhysicalByEan EAN=$ean ===");
|
error_log("=== DEBUT fetchPhysicalByEan EAN=$ean ===");
|
||||||
|
|
||||||
@@ -532,21 +532,25 @@ function fetchPhysicalByEan($ean, $pdo = null) {
|
|||||||
if (!empty($blurayData['aspect_ratio'])) $res['aspect_ratio'] = $blurayData['aspect_ratio'];
|
if (!empty($blurayData['aspect_ratio'])) $res['aspect_ratio'] = $blurayData['aspect_ratio'];
|
||||||
if (!empty($blurayData['publisher'])) $res['publisher'] = $blurayData['publisher'];
|
if (!empty($blurayData['publisher'])) $res['publisher'] = $blurayData['publisher'];
|
||||||
if (!empty($blurayData['format'])) $res['format'] = $blurayData['format'];
|
if (!empty($blurayData['format'])) $res['format'] = $blurayData['format'];
|
||||||
if (!empty($blurayData['poster'])) $res['poster'] = $blurayData['poster'];
|
// ⚠️ NE PAS ÉCRASER L'IMAGE DE GO-UPC
|
||||||
|
// if (!empty($blurayData['poster'])) $res['poster'] = $blurayData['poster'];
|
||||||
if (!empty($blurayData['year'])) $res['year'] = $blurayData['year'];
|
if (!empty($blurayData['year'])) $res['year'] = $blurayData['year'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. MovieCovers (par titre)
|
// 6. MovieCovers (par titre) - Pour jaquette HD FR
|
||||||
if (!empty($title)) {
|
if (!empty($title)) {
|
||||||
$mc = fetchFromMovieCovers($title, $res['year'] ?? '');
|
$mc = fetchFromMovieCovers($title, $res['year'] ?? '');
|
||||||
error_log("MOVIECOVERS -> poster='" . ($mc['poster'] ?? '') . "'");
|
error_log("MOVIECOVERS -> poster='" . ($mc['poster'] ?? '') . "'");
|
||||||
if (!empty($mc['poster'])) $res['poster'] = $mc['poster'];
|
// ⚠️ PRIORITÉ À L'IMAGE DE GO-UPC, SINON MOVIECOVERS
|
||||||
|
if (empty($res['poster']) && !empty($mc['poster'])) {
|
||||||
|
$res['poster'] = $mc['poster'];
|
||||||
|
}
|
||||||
if (!empty($mc['director'])) $res['director'] = $mc['director'];
|
if (!empty($mc['director'])) $res['director'] = $mc['director'];
|
||||||
if (!empty($mc['actors'])) $res['actors'] = $mc['actors'];
|
if (!empty($mc['actors'])) $res['actors'] = $mc['actors'];
|
||||||
if (!empty($mc['description'])) $res['description'] = $mc['description'];
|
if (!empty($mc['description'])) $res['description'] = $mc['description'];
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log("=== FIN fetchPhysicalByEan -> title FINAL='" . ($res['title'] ?? '') . "' ===");
|
error_log("=== FIN fetchPhysicalByEan -> title FINAL='" . ($res['title'] ?? '') . "' poster='" . ($res['poster'] ?? '') . "' ===");
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +670,10 @@ switch ($action) {
|
|||||||
$tmdbData = fetchTmdbPosterAndSynopsis($rawTitle, $physicalData['year'] ?? '', $pdo);
|
$tmdbData = fetchTmdbPosterAndSynopsis($rawTitle, $physicalData['year'] ?? '', $pdo);
|
||||||
|
|
||||||
$finalTitle = !empty($tmdbData['title']) ? $tmdbData['title'] : $rawTitle;
|
$finalTitle = !empty($tmdbData['title']) ? $tmdbData['title'] : $rawTitle;
|
||||||
$poster = ($tmdbData['poster'] !== 'assets/img/default_physical_media.jpg') ? $tmdbData['poster'] : ($physicalData['poster'] ?? '');
|
|
||||||
|
// ✅ PRIORITÉ À L'IMAGE DE GO-UPC/PHYSICAL DATA
|
||||||
|
$poster = !empty($physicalData['poster']) ? $physicalData['poster'] :
|
||||||
|
(($tmdbData['poster'] !== 'assets/img/default_physical_media.jpg') ? $tmdbData['poster'] : 'assets/img/default_physical_media.jpg');
|
||||||
|
|
||||||
$year = $tmdbData['year'] ?? $physicalData['year'] ?? '';
|
$year = $tmdbData['year'] ?? $physicalData['year'] ?? '';
|
||||||
$id = makeStableId('videotheque', $finalTitle, $year);
|
$id = makeStableId('videotheque', $finalTitle, $year);
|
||||||
@@ -685,7 +692,7 @@ switch ($action) {
|
|||||||
echo json_encode(["success" => true, "title" => $finalTitle, "director" => $tmdbData['director'] ?: ($physicalData['director'] ?? ''), "year" => $year]);
|
echo json_encode(["success" => true, "title" => $finalTitle, "director" => $tmdbData['director'] ?: ($physicalData['director'] ?? ''), "year" => $year]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'import_batch':
|
case 'import_batch':
|
||||||
checkAuth($pdo);
|
checkAuth($pdo);
|
||||||
$type = $data['type'] ?? '';
|
$type = $data['type'] ?? '';
|
||||||
$items = $data['items'] ?? [];
|
$items = $data['items'] ?? [];
|
||||||
@@ -708,7 +715,10 @@ switch ($action) {
|
|||||||
$discs = $physicalData['number_of_discs'] ?: 1;
|
$discs = $physicalData['number_of_discs'] ?: 1;
|
||||||
$aspect = $physicalData['aspect_ratio'] ?? '';
|
$aspect = $physicalData['aspect_ratio'] ?? '';
|
||||||
$length = $physicalData['length'] ?? '';
|
$length = $physicalData['length'] ?? '';
|
||||||
$poster = $physicalData['poster'] ?? '';
|
|
||||||
|
// ✅ PRIORITÉ À L'IMAGE DE GO-UPC
|
||||||
|
$poster = !empty($physicalData['poster']) ? $physicalData['poster'] : 'assets/img/default_physical_media.jpg';
|
||||||
|
|
||||||
$desc = $physicalData['description'] ?? '';
|
$desc = $physicalData['description'] ?? '';
|
||||||
$director = $physicalData['director'] ?? '';
|
$director = $physicalData['director'] ?? '';
|
||||||
$actors = $physicalData['actors'] ?? '';
|
$actors = $physicalData['actors'] ?? '';
|
||||||
@@ -716,7 +726,10 @@ switch ($action) {
|
|||||||
if (empty($poster) || empty($director) || empty($actors) || empty($desc) || empty($title)) {
|
if (empty($poster) || empty($director) || empty($actors) || empty($desc) || empty($title)) {
|
||||||
$tmdb = fetchTmdbPosterAndSynopsis($title, $year, $pdo);
|
$tmdb = fetchTmdbPosterAndSynopsis($title, $year, $pdo);
|
||||||
if (empty($title)) $title = $tmdb['title'] ?? "EAN: $ean";
|
if (empty($title)) $title = $tmdb['title'] ?? "EAN: $ean";
|
||||||
if (empty($poster) || $poster === 'assets/img/default_physical_media.jpg') $poster = $tmdb['poster'];
|
// ⚠️ NE PAS ÉCRASER L'IMAGE DE GO-UPC
|
||||||
|
if (empty($poster) && $tmdb['poster'] !== 'assets/img/default_physical_media.jpg') {
|
||||||
|
$poster = $tmdb['poster'];
|
||||||
|
}
|
||||||
if (empty($director)) $director = $tmdb['director'] ?? '';
|
if (empty($director)) $director = $tmdb['director'] ?? '';
|
||||||
if (empty($actors)) $actors = $tmdb['actors'] ?? '';
|
if (empty($actors)) $actors = $tmdb['actors'] ?? '';
|
||||||
if (empty($desc)) $desc = $tmdb['description'] ?? '';
|
if (empty($desc)) $desc = $tmdb['description'] ?? '';
|
||||||
|
|||||||
Reference in New Issue
Block a user