Actualiser js/admin.js

This commit is contained in:
2026-06-30 12:30:56 +02:00
parent 00cc9b851f
commit 174eccdb60
+17 -7
View File
@@ -412,11 +412,24 @@ async function handleCritiqueUpload(input) {
loadDashboardData(); loadDashboardData();
} }
// Extraction stricte de l'EAN uniquement // Extraction des données du CSV + EAN
function normalizeVideothequeRow(row) { function normalizeVideothequeRow(row) {
let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || ''; let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || '';
if (ean) ean = String(ean).replace(/[^0-9]/g, ''); if (ean) ean = String(ean).replace(/[^0-9]/g, '');
return { ean };
let title = row['title'] ? String(row['title']).trim() : '';
if (!ean && !title) return null; // On garde la ligne si au moins le titre ou l'EAN existe
return {
ean: ean,
title: title,
publisher: row['publisher'] || '',
length: row['length'] || '',
number_of_discs: row['number_of_discs'] || 1,
aspect_ratio: row['aspect_ratio'] || '',
description: row['description'] || '',
actors: row['creators'] || '' // Le CSV utilise 'creators' pour le casting/réalisateur
};
} }
function handleVideothequeUpload(input) { function handleVideothequeUpload(input) {
@@ -428,12 +441,9 @@ function handleVideothequeUpload(input) {
const parsed = parseCSV(text); const parsed = parseCSV(text);
if (!parsed.length) { alert("❌ CSV vide."); return; } if (!parsed.length) { alert("❌ CSV vide."); return; }
const items = parsed.map(row => { const items = parsed.map(row => normalizeVideothequeRow(row)).filter(Boolean);
const { ean } = normalizeVideothequeRow(row);
return (ean && ean.length >= 8) ? { ean } : null;
}).filter(Boolean);
if (!items.length) { alert("❌ Aucun EAN valide trouvé."); return; } if (!items.length) { alert("❌ Aucun titre ou EAN valide trouvé."); return; }
showImportModal(items.length, 'videotheque'); showImportModal(items.length, 'videotheque');
let processed = 0, totalImp = 0, totalSkp = 0; let processed = 0, totalImp = 0, totalSkp = 0;