Commit 1b2d8f92 authored by nanahira's avatar nanahira

rewrite

parent 91a62fd6
......@@ -20,14 +20,14 @@ const courseTypes = {
async function main() {
const category_array = await fs.promises.readdir(fpath);
for (let category_raw of category_array) {
for (let category_raw of category_array) {
const category = parseInt(category_raw);
if (isNaN(category))
continue;
const category_path = fpath + "/" + category;
//console.log("Reading: " + category_path);
const songs = await fs.promises.readdir(category_path);
for (let song_raw of songs) {
for (let song_raw of songs) {
const song_id = parseInt(song_raw);
if (isNaN(song_id))
continue;
......@@ -43,7 +43,22 @@ async function main() {
//const tja_text = encoded_buf.toString('utf8');
const tja_lines = tja_text.split("\n");
let res = {
skin_id: null,
title: null,
category_id: category,
enabled: true,
type: "tja",
courses: {
easy: null,
normal: null,
hard: null,
oni: null,
ura: null,
},
volume: 1,
id: song_id,
preview: null,
order: song_id,
title_lang: {
ja: null,
en: null,
......@@ -51,6 +66,9 @@ async function main() {
tw: null,
ko: null
},
hash: tja_hash,
offset: process.env.OFFSET ? parseFloat(process.env.OFFSET) : -0.023,
maker_id: process.env.MAKER ? parseFloat(process.env.MAKER) : null,
subtitle: null,
subtitle_lang: {
ja: null,
......@@ -59,31 +77,11 @@ async function main() {
tw: null,
ko: null
},
courses: {
easy: null,
normal: null,
hard: null,
oni: null,
ura: null,
},
id: song_id,
category_id: category,
type: "tja",
enabled: true,
preview: null,
branch: {
easy: false,
normal: false,
hard: false,
oni: false,
ura: false,
},
hash: tja_hash
}
let courseName = "oni";
for (let line of tja_lines) {
for (let line of tja_lines) {
const line_ = line.trim();
if (line_.indexOf(":") > 0) {
if (line_.indexOf(":") > 0) {
//const line__ = convert(line_, "UTF-8", "SHIFT-JIS").toString('utf8');
const temp = line_.split(":");
const key = temp[0].toLowerCase();
......@@ -91,36 +89,30 @@ async function main() {
//console.log("Find value: " + key +" --> " + value);
switch (key) {
case "title":
res.title = value.replace("'","''");
res.title = value;
break;
case "subtitle":
res.subtitle = value.replace("'","''");
res.subtitle = value;
break;
case "demostart":
res.preview = value;
res.preview = parseFloat(volume);
case "course":
const diff = value.toLowerCase();
if(diff in courseTypes){
if (diff in courseTypes) {
courseName = courseTypes[diff];
}else{
} else {
courseName = diff;
}
break;
case "level":
res.courses[courseName] = value;
case "level":
res.courses[courseName] = {
stars: parseInt(value),
branch: false
};
break;
}
} else if (line_.startsWith("#BRANCHSTART")) {
res.branch[courseName] = true;
}
}
for (let diff of ["easy", "normal", "hard", "oni", "ura"]) {
if (res.courses[diff]) {
if (res.branch[diff]) {
res.courses[diff] = "'" + res.courses[diff] + " B'";
} else {
res.courses[diff] = "'" + res.courses[diff] + "'";
}
res.courses[courseName].branch = true;
}
}
all_songs.push(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment