From d7e27394faa30fb9cc8729ada6644999aeeed91a Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 30 Jun 2026 16:02:19 +0200 Subject: [PATCH] Actualiser api.php --- api.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/api.php b/api.php index 96c1c45..4c06bab 100644 --- a/api.php +++ b/api.php @@ -500,6 +500,66 @@ function fetchFromBlurayCom($ean) { return $empty; } +function fetchFromMovieCovers($title, $year = '') { + $empty = [ + 'title' => '', 'year' => '', 'director' => '', 'actors' => '', + 'poster' => '', 'description' => '', 'length' => '', + 'publisher' => '', 'format' => 'DVD', 'number_of_discs' => 1, + 'aspect_ratio' => '' + ]; + + // Nettoyer le titre pour l'URL + $urlTitle = strtoupper(str_replace(' ', '+', $title)); + $url = "https://moviecovers.com/film/titre_{$urlTitle}.html"; + + $html = httpGet($url, 10); + if (!$html) return $empty; + + // Extraire le titre + if (preg_match('/([^<]+)<\/TITLE>/i', $html, $m)) { + $empty['title'] = trim($m[1]); + } + + // Extraire l'affiche + if (preg_match('/<img[^>]*src="(https:\/\/moviecovers\.com\/DATA\/thumbs\/[^"]+)"[^>]*title="Recto/i', $html, $m)) { + $empty['poster'] = $m[1]; + } elseif (preg_match('/<meta[^>]*property="og:image"[^>]*content="([^"]+)"/i', $html, $m)) { + $empty['poster'] = $m[1]; + } + + // Extraire le réalisateur + if (preg_match('/Réalisateur<\/TH>\s*<TD[^>]*>.*?<a[^>]*>([^<]+)<\/a>/is', $html, $m)) { + $empty['director'] = trim($m[1]); + } + + // Extraire l'année + if (preg_match('/Année<\/TH>\s*<TD[^>]*>.*?<a[^>]*>(\d{4})<\/a>/is', $html, $m)) { + $empty['year'] = $m[1]; + } + + // Extraire la durée + if (preg_match('/Durée<\/TH>\s*<TD[^>]*>([\dH]+[\dmin]*)/is', $html, $m)) { + $empty['length'] = trim($m[1]); + } + + // Extraire les acteurs + if (preg_match_all('/<a href="\/multicrit\.html\?acteur=[^"]*">([^<]+)<\/a>/i', $html, $matches)) { + $empty['actors'] = implode(', ', array_slice($matches[1], 0, 5)); + } + + // Extraire le synopsis + if (preg_match('/<meta[^>]*property="og:description"[^>]*content="([^"]+)"/i', $html, $m)) { + $empty['description'] = html_entity_decode($m[1]); + } + + // Format haute qualité de l'affiche + if ($empty['poster']) { + $empty['poster'] = str_replace('/thumbs/', '/films-l/', $empty['poster']); + } + + return $empty; +} + // ── ROUTEUR PRINCIPAL ── $action = $_GET['action'] ?? ''; $data = json_decode(file_get_contents('php://input'), true) ?? [];