Add duplicate detection with fuzzy matching and fix artist metadata extraction
This commit is contained in:
@@ -462,6 +462,16 @@ export default function AdminPage() {
|
||||
song: data.song,
|
||||
validation: data.validation
|
||||
});
|
||||
} else if (res.status === 409) {
|
||||
// Duplicate detected
|
||||
const data = await res.json();
|
||||
results.push({
|
||||
filename: file.name,
|
||||
success: false,
|
||||
isDuplicate: true,
|
||||
duplicate: data.duplicate,
|
||||
error: `Duplicate: Already exists as "${data.duplicate.title}" by "${data.duplicate.artist}"`
|
||||
});
|
||||
} else {
|
||||
results.push({
|
||||
filename: file.name,
|
||||
@@ -486,12 +496,24 @@ export default function AdminPage() {
|
||||
|
||||
// Auto-trigger categorization after uploads
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
const duplicateCount = results.filter(r => r.isDuplicate).length;
|
||||
const failedCount = results.filter(r => !r.success && !r.isDuplicate).length;
|
||||
if (successCount > 0) {
|
||||
setMessage(`✅ Uploaded ${successCount}/${files.length} songs successfully!\n\n🤖 Starting auto-categorization...`);
|
||||
let msg = `✅ Uploaded ${successCount}/${files.length} songs successfully!`;
|
||||
if (duplicateCount > 0) {
|
||||
msg += `\n⚠️ Skipped ${duplicateCount} duplicate(s)`;
|
||||
}
|
||||
if (failedCount > 0) {
|
||||
msg += `\n❌ ${failedCount} failed`;
|
||||
}
|
||||
msg += '\n\n🤖 Starting auto-categorization...';
|
||||
setMessage(msg);
|
||||
// Small delay to let user see the message
|
||||
setTimeout(() => {
|
||||
handleAICategorization();
|
||||
}, 1000);
|
||||
} else if (duplicateCount > 0 && failedCount === 0) {
|
||||
setMessage(`⚠️ All ${duplicateCount} file(s) were duplicates - nothing uploaded.`);
|
||||
} else {
|
||||
setMessage(`❌ All uploads failed.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user