data: switch to recovered game DB and refresh cards and charts
Publish GitHub Pages output / publish (push) Successful in 44s
Publish GitHub Pages output / publish (push) Successful in 44s
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
import { readHolodoriDbTable } from './holodoridb-source.mjs';
|
||||
import { readGameDbTable } from './game-db-source.mjs';
|
||||
import { readFile, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
const projectRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/(?=[A-Za-z]:)/, '')), '..');
|
||||
const catalogPath = path.join(projectRoot, 'src/lib/data/exact-chart-catalog.json');
|
||||
const musicRows = readHolodoriDbTable('kor', 'Music.json');
|
||||
const musicRows = readGameDbTable('kor', 'Music.json');
|
||||
const musicById = new Map(musicRows.map((row) => [row.data?.id ?? row.id, row.data ?? row]));
|
||||
const singerMetadataOverrides = {
|
||||
m0334: { singerType: 'solo', singerCharacterIds: ['chr-04001'] }
|
||||
};
|
||||
|
||||
const compactSingerType = (value) => typeof value === 'string' ? value.split('_').at(-1)?.toLowerCase() ?? null : null;
|
||||
const catalog = JSON.parse(await readFile(catalogPath, 'utf8'));
|
||||
|
||||
for (const entry of catalog.charts) {
|
||||
const music = musicById.get(entry.songId);
|
||||
const singerOverride = singerMetadataOverrides[entry.songId];
|
||||
entry.singerType = singerOverride?.singerType ?? compactSingerType(music?.musicSingerType);
|
||||
entry.singerCharacterIds = singerOverride?.singerCharacterIds ?? music?.characterIds ?? [];
|
||||
if (!music) throw new Error(`Missing DB song: ${entry.songId}`);
|
||||
entry.singerType = compactSingerType(music?.musicSingerType);
|
||||
entry.singerCharacterIds = music?.characterIds ?? [];
|
||||
const chartPath = path.join(projectRoot, 'static', entry.path.replace(/^\//, '').replace(/^data[\\/]charts[\\/]/, 'data/charts/'));
|
||||
const chart = JSON.parse(await readFile(chartPath, 'utf8'));
|
||||
chart.singerType = entry.singerType;
|
||||
|
||||
Reference in New Issue
Block a user