-
Notifications
You must be signed in to change notification settings - Fork 1
/
mappoolgen.js
52 lines (45 loc) · 1.36 KB
/
mappoolgen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { v2, auth } = require("osu-api-extended");
const fs = require("fs");
const config = require("./config.js");
const mappoolCSV = fs
.readFileSync("./mappool.csv", { encoding: "utf8", flag: "r" })
.trim()
.split(/\r?\n/);
let maps = {};
let mappool = [];
mappoolCSV.forEach((line) => {
const spl = line.split(",");
maps[spl[0].trim()] = parseInt(spl[1]);
});
const call = async () => {
const SCOPE_LIST = ["public"];
// Auth via client
await auth.login(config.clientID, config.clientSecret, SCOPE_LIST);
for (const code of Object.keys(maps)) {
const data = await v2.beatmap.id.details(maps[code]);
mappool.push({
map_id: maps[code],
mapset_id: data.beatmapset_id,
code: code,
background: `https://assets.ppy.sh/beatmaps/${data.beatmapset_id}/covers/raw.jpg`,
cover: data.beatmapset.covers["cover@2x"],
title: data.beatmapset.title,
artist: data.beatmapset.artist,
mapper: data.beatmapset.creator,
difficulty: data.version,
stats: {
cs: data.cs,
ar: data.ar,
od: data.accuracy,
hp: data.drain,
sr: data.difficulty_rating,
bpm: data.bpm,
length: data.total_length * 1000,
},
});
}
};
call().then(() => {
console.log({ mappool: mappool });
fs.writeFileSync("./mappool.json", JSON.stringify({ mappool: mappool }, null, 2));
});