Migrate BMS Songs-Charts

Fixes #9
This commit is contained in:
zkldi
2021-05-24 11:07:04 +01:00
parent a56378fe47
commit 99ee3e9bb5
2 changed files with 88 additions and 0 deletions
+3
View File
@@ -13,3 +13,6 @@ coverage
scripts/arc-db-sync/charts.json
scripts/arc-db-sync/songs.json
scripts/validate-database-errs/*
scripts/parse-beatoraja-mdb/*
!scripts/parse-beatoraja-mdb/main.ts
@@ -0,0 +1,85 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-nocheck
// yeah, this script is old and wrote in JS. what of it.
const sqlDB = require("better-sqlite3")("songdata.db");
const fs = require("fs");
console.log("Connecting to database...");
console.time("DB CONNECT TIME");
const crypto = require("crypto");
const ktchiSongs = [];
const ktchiCharts = [];
const stmt = sqlDB.prepare("SELECT * FROM song");
let freeSongID = 1;
const DIFFICULTY_LOOKUP = ["CUSTOM", "BEGINNER", "NORMAL", "HYPER", "ANOTHER", "CUSTOM"];
const PLAYTYPE_LOOKUP = {
7: "7K",
14: "14K",
5: "5K",
10: "10K",
};
for (const song of stmt.iterate()) {
const playtype = PLAYTYPE_LOOKUP[song.mode.toString()];
const songID = freeSongID;
const chartID = crypto.randomBytes(20).toString("hex");
let difficulty = DIFFICULTY_LOOKUP[song.difficulty];
freeSongID++;
if (!difficulty) {
console.log(song.difficulty);
difficulty = "CUSTOM"; // fuck it and fuck you, you bitch.
}
const ktchiChart = {
songID,
chartID: chartID,
rgcID: null,
data: {
notecount: song.notes,
hashMD5: song.md5,
hashSHA256: song.sha256,
},
level: "?",
levelNum: 0,
difficulty,
playtype,
isPrimary: true,
versions: [],
};
const ktchiSong = {
id: songID,
title: song.title,
artist: song.artist,
firstVersion: null,
data: {
subtitle: song.subtitle ?? null,
subartist: song.subartist ?? null,
genre: song.genre ?? null,
},
"search-titles": [],
"alt-titles": [],
};
ktchiSongs.push(ktchiSong);
ktchiCharts.push(ktchiChart);
}
console.log("done");
fs.writeFileSync("songs.json", JSON.stringify(ktchiSongs));
fs.writeFileSync("charts.json", JSON.stringify(ktchiCharts));
console.log("postwrite");