Actualiser api.php

This commit is contained in:
2026-06-25 13:20:28 +02:00
parent ec77829a2f
commit 5515b62dcd
+29 -8
View File
@@ -560,19 +560,40 @@ switch ($action) {
}
break;
case 'debug_dvdcover':
case 'debug_dvdcover':
$title = $_GET['title'] ?? '';
$year = $_GET['year'] ?? '';
$year = $_GET['year'] ?? '';
$format = $_GET['format'] ?? 'Blu-ray';
if (!$title) { echo json_encode(['error' => 'Titre manquant']); exit; }
$result = ['title' => $title, 'year' => $year, 'format' => $format];
$data = fetchDVDCover($title, $year, $format);
$result['data'] = $data;
$result['status'] = $data ? 'OK' : 'AUCUN_RÉSULTAT';
$ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
$searchUrl = "https://www.dvdcover.com/?s=" . urlencode(cleanTitle($title));
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
$html = httpGet($searchUrl, 10, $ua);
$diag = [
'url' => $searchUrl,
'html_length' => $html ? strlen($html) : 0,
'html_snippet' => $html ? substr(strip_tags($html), 0, 500) : 'VIDE/ERREUR',
'cloudflare' => ($html && strpos($html, 'cloudflare') !== false) ? true : false,
'captcha' => ($html && strpos($html, 'captcha') !== false) ? true : false,
];
// Cherche les articles si HTML reçu
if ($html) {
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$links = $xpath->query('//article[contains(@class,"post")]//a/@href');
$diag['articles_found'] = $links->length;
// Essai avec d'autres sélecteurs courants
$diag['alt1_h2_links'] = $xpath->query('//h2//a/@href')->length;
$diag['alt2_figure_imgs'] = $xpath->query('//figure//img/@src')->length;
$diag['alt3_any_article'] = $xpath->query('//article')->length;
}
echo json_encode($diag, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
exit;
break;
}