feat(scraper): implement One Piece data scraper for devil fruits and characters

- Added a new script to scrape devil fruits and characters from One Piece fandom.
- Implemented functions to fetch, normalize, and save data in JSON, CSV, and SQL formats.
- Created a structured output directory for scraped data.

feat(database): update schema for devil fruits and characters

- Defined new types for devil fruits and haki in the database schema.
- Updated the character table to include fields for age, affiliations, devil fruit, haki, bounty, height, origin, first appearance, and picture URL.

feat(ui): enhance main page and daily mode layout

- Redesigned the main page with a new layout and styling for the OnePieceDle game.
- Created a new daily mode page with sections for clues and user input for guesses.
- Removed demo authentication routes and pages to streamline the application.
This commit is contained in:
2026-02-27 01:14:44 +01:00
parent c494866a70
commit 6f7bae2307
17 changed files with 2407 additions and 165 deletions

104
scripts/import-sql.js Normal file
View File

@@ -0,0 +1,104 @@
import { createClient } from '@libsql/client';
import fs from 'fs';
// Load environment variables
const DATABASE_URL = process.env.DATABASE_URL || 'file:local.db';
const client = createClient({
url: DATABASE_URL
});
async function importSQL() {
try {
let totalSuccess = 0;
let totalErrors = 0;
// Step 1: Import Devil Fruits
if (fs.existsSync('./scraped-data/devil-fruits.sql')) {
console.log('\n=== Importing Devil Fruits ===\n');
const devilFruitsSql = fs.readFileSync('./scraped-data/devil-fruits.sql', 'utf-8');
const dfStatements = devilFruitsSql.split(';\n\n').filter(s => s.trim());
console.log(`Found ${dfStatements.length} devil fruit statements\n`);
let successCount = 0;
let errorCount = 0;
for (let i = 0; i < dfStatements.length; i++) {
const statement = dfStatements[i];
if (statement.trim()) {
try {
await client.execute(statement.trim() + ';');
successCount++;
process.stdout.write(`\rExecuted: ${successCount}/${dfStatements.length}`);
} catch (error) {
errorCount++;
const valuesMatch = statement.match(/VALUES\s*\(([^)]+)\)/);
const values = valuesMatch ? valuesMatch[1] : 'N/A';
console.error(`\n✗ Error at statement ${i + 1}:`);
console.error(` Values: ${values}`);
console.error(` Message: ${error.message}`);
}
}
}
console.log(`\n\n✓ Devil Fruits imported!`);
console.log(` Success: ${successCount}`);
console.log(` Errors: ${errorCount}`);
totalSuccess += successCount;
totalErrors += errorCount;
} else {
console.log('\n⚠ No devil-fruits.sql found, skipping...\n');
}
// Step 2: Import Characters
if (fs.existsSync('./scraped-data/characters.sql')) {
console.log('\n=== Importing Characters ===\n');
const charactersSql = fs.readFileSync('./scraped-data/characters.sql', 'utf-8');
const charStatements = charactersSql.split(';\n\n').filter(s => s.trim());
console.log(`Found ${charStatements.length} character statements\n`);
let successCount = 0;
let errorCount = 0;
for (let i = 0; i < charStatements.length; i++) {
const statement = charStatements[i];
if (statement.trim()) {
try {
await client.execute(statement.trim() + ';');
successCount++;
process.stdout.write(`\rExecuted: ${successCount}/${charStatements.length}`);
} catch (error) {
errorCount++;
const valuesMatch = statement.match(/VALUES\s*\(([^)]+)\)/);
const values = valuesMatch ? valuesMatch[1] : 'N/A';
console.error(`\n✗ Error at statement ${i + 1}:`);
console.error(` Values: ${values}`);
console.error(` Message: ${error.message}`);
}
}
}
console.log(`\n\n✓ Characters imported!`);
console.log(` Success: ${successCount}`);
console.log(` Errors: ${errorCount}`);
totalSuccess += successCount;
totalErrors += errorCount;
} else {
console.log('\n⚠ No characters.sql found, skipping...\n');
}
console.log(`\n=== Total Import Summary ===`);
console.log(` Total Success: ${totalSuccess}`);
console.log(` Total Errors: ${totalErrors}\n`);
} catch (error) {
console.error('✗ Import failed:', error.message);
process.exit(1);
}
}
importSQL().catch(console.error);