]*class="[^"]*film_affiche[^"]*"[^>]*>.*?
![]()
]*src="([^"]+)"/is', $filmRes, $imgMatches)) {
+ $posterUrl = $imgMatches[1];
+ } elseif (preg_match('/
![]()
]*src="(https:\/\/www\.notrecinema\.com\/images\/films\/[^"]+)"/i', $filmRes, $imgMatches)) {
+ $posterUrl = $imgMatches[1];
+ }
+
+ if (!empty($posterUrl)) {
+ // S'assurer que l'URL est absolue
+ if (strpos($posterUrl, 'http') !== 0) {
+ $posterUrl = 'https://www.notrecinema.com' . $posterUrl;
+ }
return [
'poster' => $posterUrl,
- 'title' => $title,
+ 'title' => $cleanTitle,
'format' => 'Blu-ray'
];
}
@@ -164,33 +176,30 @@ function fetchBluRayCom($ean, $title = '', $year = '', $pdo = null) {
}
}
- // Fallback : recherche par titre
- if (!empty($title)) {
- $cleanTitle = cleanTitle($title);
- $searchUrl = "https://www.blu-ray.com/search/?quicksearch=1&searchtype=movies&q=" . urlencode($cleanTitle);
+ // ÉTAPE 2 : Recherche alternative par EAN si disponible
+ if (!empty($ean)) {
+ $cleanEan = preg_replace('/[^0-9]/', '', $ean);
+ $searchUrl = "https://www.notrecinema.com/communaute/recherche.php?recherche=" . urlencode($cleanEan);
- $searchRes = httpGet($searchUrl, 5, $userAgent);
+ $searchRes = httpGet($searchUrl, 10, $userAgent);
- if ($searchRes && preg_match('/
]*>/i', $searchRes, $matches)) {
- $movieId = $matches[1];
- $movieUrl = "https://www.blu-ray.com/movies/?id=" . $movieId;
+ if ($searchRes && preg_match('/]*>/i', $searchRes, $matches)) {
+ $filmSlug = $matches[1];
+ $filmUrl = "https://www.notrecinema.com/communaute/stubs.php?stub=" . $filmSlug;
- $movieRes = httpGet($movieUrl, 5, $userAgent);
+ $filmRes = httpGet($filmUrl, 10, $userAgent);
- if ($movieRes && preg_match('/
]*id="home_release_img"[^>]*src="([^"]+)"/i', $movieRes, $imgMatches)) {
- $posterUrl = $imgMatches[1];
- $posterUrl = str_replace('/resized/', '/', $posterUrl);
-
+ if ($filmRes && preg_match('/
]*src="(https:\/\/www\.notrecinema\.com\/images\/films\/[^"]+)"/i', $filmRes, $imgMatches)) {
return [
- 'poster' => $posterUrl,
- 'title' => $title,
+ 'poster' => $imgMatches[1],
+ 'title' => $cleanTitle,
'format' => 'Blu-ray'
];
}
}
}
- return ['poster' => $defaultPoster, 'title' => $title, 'format' => 'Blu-ray'];
+ return ['poster' => $defaultPoster, 'title' => $cleanTitle, 'format' => 'Blu-ray'];
}
// ── ROUTEUR PRINCIPAL ──
@@ -483,64 +492,64 @@ case 'get_config_keys':
else { http_response_code(400); echo json_encode(["success" => false, "error" => "Aucun élément sélectionné."]); }
break;
- case 'import_batch':
- checkAuth($pdo);
- $data = json_decode(file_get_contents("php://input"), true);
- $type = $data['type'] ?? 'critique';
- $items = $data['items'] ?? [];
+ case 'import_batch':
+ checkAuth($pdo);
+ $data = json_decode(file_get_contents("php://input"), true);
+ $type = $data['type'] ?? 'critique';
+ $items = $data['items'] ?? [];
+
+ $pdo->beginTransaction();
+ $imported = 0;
+
+ if ($type === 'videotheque') {
+ $stmtVideo = $pdo->prepare("INSERT INTO videotheque (id, title, year, format, poster, ean_isbn13, description, length, number_of_discs, aspect_ratio, actors, publisher, director)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ON DUPLICATE KEY UPDATE
+ ean_isbn13 = VALUES(ean_isbn13),
+ poster = VALUES(poster),
+ description = VALUES(description),
+ format = VALUES(format),
+ length = VALUES(length),
+ number_of_discs = VALUES(number_of_discs),
+ aspect_ratio = VALUES(aspect_ratio),
+ actors = VALUES(actors),
+ publisher = VALUES(publisher)");
- $pdo->beginTransaction();
- $imported = 0;
-
- if ($type === 'videotheque') {
- $stmtVideo = $pdo->prepare("INSERT INTO videotheque (id, title, year, format, poster, ean_isbn13, description, length, number_of_discs, aspect_ratio, actors, publisher, director)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- ON DUPLICATE KEY UPDATE
- ean_isbn13 = VALUES(ean_isbn13),
- poster = VALUES(poster),
- description = VALUES(description),
- format = VALUES(format),
- length = VALUES(length),
- number_of_discs = VALUES(number_of_discs),
- aspect_ratio = VALUES(aspect_ratio),
- actors = VALUES(actors),
- publisher = VALUES(publisher)");
+ foreach ($items as $item) {
+ $title = $item['title'] ?? '';
+ if (empty($title)) continue;
- foreach ($items as $item) {
- $title = $item['title'] ?? '';
- if (empty($title)) continue;
-
- $year = $item['year'] ?? '';
- $ean = $item['ean'] ?? '';
- $desc = $item['description'] ?? '';
- $length = $item['length'] ?? '';
- $discs = $item['number_of_discs'] ?? 1;
- $aspect = $item['aspect_ratio'] ?? '';
- $actors = $item['actors'] ?? '';
- $publisher = $item['publisher'] ?? '';
- $director = $item['director'] ?? '';
-
- $id = makeStableId('videotheque', $title, $year);
-
- // Utiliser blu-ray.com pour récupérer l'image
- $bluRayData = fetchBluRayCom($ean, $title, $year, $pdo);
- $poster = $bluRayData['poster'];
-
- // Déterminer le format
- $format = 'Blu-ray';
- if (stripos($title, '4K') !== false || stripos($title, 'UHD') !== false) {
- $format = '4K Ultra HD';
- } elseif (stripos($desc, 'DVD') !== false) {
- $format = 'DVD';
- }
-
- $stmtVideo->execute([
- $id, $title, $year, $format, $poster, $ean, $desc,
- $length, $discs, $aspect, $actors, $publisher, $director
- ]);
- $imported++;
+ $year = $item['year'] ?? '';
+ $ean = $item['ean'] ?? '';
+ $desc = $item['description'] ?? '';
+ $length = $item['length'] ?? '';
+ $discs = $item['number_of_discs'] ?? 1;
+ $aspect = $item['aspect_ratio'] ?? '';
+ $actors = $item['actors'] ?? '';
+ $publisher = $item['publisher'] ?? '';
+ $director = $item['director'] ?? '';
+
+ $id = makeStableId('videotheque', $title, $year);
+
+ // Utiliser notrecinema.com pour récupérer l'image
+ $notreCinemaData = fetchNotreCinema($title, $year, $ean, $pdo);
+ $poster = $notreCinemaData['poster'];
+
+ // Déterminer le format
+ $format = 'Blu-ray';
+ if (stripos($title, '4K') !== false || stripos($title, 'UHD') !== false) {
+ $format = '4K Ultra HD';
+ } elseif (stripos($desc, 'DVD') !== false) {
+ $format = 'DVD';
}
- } else {
+
+ $stmtVideo->execute([
+ $id, $title, $year, $format, $poster, $ean, $desc,
+ $length, $discs, $aspect, $actors, $publisher, $director
+ ]);
+ $imported++;
+ }
+ } else {
$ratingRaw = $rowData['Rating'] ?? $rowData['rating'] ?? '';
$rating = ($ratingRaw !== '' && $ratingRaw !== null) ? (float)$ratingRaw : null;
$review = $rowData['Review'] ?? $rowData['review'] ?? '';