Actualiser api.php
This commit is contained in:
@@ -137,6 +137,34 @@ function fetchUPCitemdb($ean, $pdo) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── 1.5 API DVDFr (Spécial Jaquettes Physiques FR) ──
|
||||||
|
function fetchDVDFr($ean, $pdo) {
|
||||||
|
if (empty($ean) || strlen($ean) < 8) return null;
|
||||||
|
$cacheKey = 'dvdfr_' . md5($ean);
|
||||||
|
|
||||||
|
$cached = getCache($pdo, $cacheKey);
|
||||||
|
if ($cached) return $cached;
|
||||||
|
|
||||||
|
$url = "https://www.dvdfr.com/api/search.php?gencode=" . urlencode($ean);
|
||||||
|
$res = httpGet($url, 5);
|
||||||
|
if (!$res) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// DVDFr renvoie du XML, on le parse silencieusement (@)
|
||||||
|
$xml = @simplexml_load_string($res);
|
||||||
|
if ($xml && isset($xml->dvd) && isset($xml->dvd[0]->cover)) {
|
||||||
|
$poster = (string)$xml->dvd[0]->cover;
|
||||||
|
if (!empty($poster)) {
|
||||||
|
setCache($pdo, $cacheKey, $poster, 'dvdfr');
|
||||||
|
return $poster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// ── 2. API TMDB (Full Extract avec Synopsis et Acteurs) ──
|
// ── 2. API TMDB (Full Extract avec Synopsis et Acteurs) ──
|
||||||
function fetchTMDBFull($title, $year, $apiKey, $pdo) {
|
function fetchTMDBFull($title, $year, $apiKey, $pdo) {
|
||||||
if (empty($apiKey) || empty($title)) return null;
|
if (empty($apiKey) || empty($title)) return null;
|
||||||
@@ -288,6 +316,12 @@ switch ($action) {
|
|||||||
$result['publisher'] = $upcData['publisher'];
|
$result['publisher'] = $upcData['publisher'];
|
||||||
$result['format'] = $upcData['format'];
|
$result['format'] = $upcData['format'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔥 NOUVEAU : DVDFr pour remplacer l'affiche lors d'un ajout manuel
|
||||||
|
$dvdfrCover = fetchDVDFr($ean, $pdo);
|
||||||
|
if (!empty($dvdfrCover)) {
|
||||||
|
$result['poster'] = $dvdfrCover;
|
||||||
|
}
|
||||||
$tmdbKey = getTmdbApiKey($pdo);
|
$tmdbKey = getTmdbApiKey($pdo);
|
||||||
if ($tmdbKey && $tmdbQueryTitle) {
|
if ($tmdbKey && $tmdbQueryTitle) {
|
||||||
$tmdbData = fetchTMDBFull($tmdbQueryTitle, '', $tmdbKey, $pdo);
|
$tmdbData = fetchTMDBFull($tmdbQueryTitle, '', $tmdbKey, $pdo);
|
||||||
@@ -402,6 +436,12 @@ switch ($action) {
|
|||||||
if (empty($publisher)) $publisher = $upcData['publisher'];
|
if (empty($publisher)) $publisher = $upcData['publisher'];
|
||||||
if (empty($format) || $format === 'Blu-ray') $format = $upcData['format'];
|
if (empty($format) || $format === 'Blu-ray') $format = $upcData['format'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔥 NOUVEAU : 1.5 DVDFr (Écrase l'affiche UPC avec la vraie jaquette FR)
|
||||||
|
$dvdfrCover = fetchDVDFr($ean, $pdo);
|
||||||
|
if (!empty($dvdfrCover)) {
|
||||||
|
$poster = $dvdfrCover;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. TMDB (Écrase les données CSV avec les données officielles)
|
// 2. TMDB (Écrase les données CSV avec les données officielles)
|
||||||
|
|||||||
Reference in New Issue
Block a user