diff --git a/api.php b/api.php index bdc299f..4097aad 100644 --- a/api.php +++ b/api.php @@ -117,66 +117,96 @@ function extractYear($dateStr) { function fetchDVDCover($title, $year = '', $format = 'bluray') { if (empty($title)) return null; - + $ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'; $cleanTitle = cleanTitle($title); - - // On encode proprement pour l'URL $searchUrl = "https://www.dvdcover.com/?s=" . urlencode($cleanTitle); - + $html = httpGet($searchUrl, 10, $ua); if (!$html) { error_log("DVDCover: Erreur réseau pour '$title'"); return null; } - // DEBUG : Sauvegarde le contenu pour vérifier si on est bloqué - file_put_contents(__DIR__ . '/debug_scrap.html', $html); - $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); - - // On cherche les liens dans les articles (Standard WordPress) - $links = $xpath->query('//article[contains(@class, "post")]//a/@href'); - + + // Les résultats sont dans des