Actualiser api.php

This commit is contained in:
2026-06-30 16:02:19 +02:00
parent 3830359247
commit d7e27394fa
+60
View File
@@ -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>([^<]+)<\/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&eacute;alisateur<\/TH>\s*<TD[^>]*>.*?<a[^>]*>([^<]+)<\/a>/is', $html, $m)) {
$empty['director'] = trim($m[1]);
}
// Extraire l'année
if (preg_match('/Ann&eacute;e<\/TH>\s*<TD[^>]*>.*?<a[^>]*>(\d{4})<\/a>/is', $html, $m)) {
$empty['year'] = $m[1];
}
// Extraire la durée
if (preg_match('/Dur&eacute;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) ?? [];