mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-07 22:38:02 +03:00
update charts-iidx indexes and commit arc-db-merge
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Command } from "commander";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import fetch from "../../src/fetch";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import fetch from "../../src/common/fetch";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
@@ -18,14 +18,14 @@ program.parse(process.argv);
|
||||
const options = program.opts();
|
||||
|
||||
async function GetIIDXSongs() {
|
||||
let allSongs = [];
|
||||
const allSongs = [];
|
||||
|
||||
let url = `https://${options.url}/api/v1/iidx/27/music/`;
|
||||
|
||||
let moreData = true;
|
||||
while (moreData) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
let songs = await fetch(url, {
|
||||
const songs = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.bearer}`,
|
||||
},
|
||||
@@ -44,12 +44,12 @@ async function GetIIDXSongs() {
|
||||
}
|
||||
|
||||
async function GetCharts() {
|
||||
let songs = JSON.parse(fs.readFileSync(path.join(__dirname, "./songs.json"), "utf-8"));
|
||||
const songs = JSON.parse(fs.readFileSync(path.join(__dirname, "./songs.json"), "utf-8"));
|
||||
|
||||
logger.info("Parsed songs.json");
|
||||
|
||||
let allCharts: any[] = [];
|
||||
let failed: any[] = [];
|
||||
const allCharts: any[] = [];
|
||||
const failed: any[] = [];
|
||||
|
||||
async function DoStuff(song: any) {
|
||||
try {
|
||||
@@ -58,7 +58,7 @@ async function GetCharts() {
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
let charts = await fetch(
|
||||
const charts = await fetch(
|
||||
`https://${options.url}/api/v1/iidx/27/charts/?music_id=${song._id}&omnimix=true`,
|
||||
{
|
||||
headers: {
|
||||
@@ -77,7 +77,7 @@ async function GetCharts() {
|
||||
}
|
||||
}
|
||||
|
||||
let promises = songs.map((s: any) => DoStuff(s));
|
||||
const promises = songs.map((s: any) => DoStuff(s));
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
|
||||
@@ -2,21 +2,21 @@ import fs from "fs";
|
||||
import { ICollection } from "monk";
|
||||
import path from "path";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import { FindChartWithPTDFVersion } from "../../src/score-import/database-lookup/chart-ptdf";
|
||||
import { FindSongOnTitle } from "../../src/score-import/database-lookup/song-title";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import { FindSongOnTitle } from "../../src/common/database-lookup/song";
|
||||
import { FindChartWithPTDFVersion } from "../../src/common/database-lookup/chart";
|
||||
|
||||
const logger = CreateLogCtx("arc-db-merge.ts");
|
||||
|
||||
async function MergeIDs() {
|
||||
let charts = JSON.parse(fs.readFileSync(path.join(__dirname, "./charts.json"), "utf-8"));
|
||||
const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "./charts.json"), "utf-8"));
|
||||
|
||||
for (const chartData of charts) {
|
||||
let songTitle = chartData._related.music[0].title;
|
||||
const songTitle = chartData._related.music[0].title;
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
let song = await FindSongOnTitle("iidx", songTitle);
|
||||
const song = await FindSongOnTitle("iidx", songTitle);
|
||||
|
||||
if (!song) {
|
||||
logger.error(`Could not resolve ${songTitle}?`);
|
||||
@@ -24,9 +24,9 @@ async function MergeIDs() {
|
||||
}
|
||||
|
||||
for (const chart of chartData._items) {
|
||||
let playtype: "SP" | "DP" = chart.play_style === "DOUBLE" ? "DP" : "SP";
|
||||
const playtype: "SP" | "DP" = chart.play_style === "DOUBLE" ? "DP" : "SP";
|
||||
let difficulty = chart.difficulty === "BLACK" ? "LEGGENDARIA" : chart.difficulty;
|
||||
let version = "27";
|
||||
const version = "27-omni";
|
||||
|
||||
// yeah this fails for wacky playtype mismatches -- i don't care.
|
||||
if (
|
||||
@@ -39,7 +39,7 @@ async function MergeIDs() {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
let ktchiChart = await FindChartWithPTDFVersion(
|
||||
const ktchiChart = await FindChartWithPTDFVersion(
|
||||
"iidx",
|
||||
song.id,
|
||||
playtype,
|
||||
@@ -70,7 +70,7 @@ async function MergeIDs() {
|
||||
}
|
||||
}
|
||||
|
||||
let r = await db.charts.iidx.update(
|
||||
const r = await db.charts.iidx.update(
|
||||
{
|
||||
"data.arcChartID": { $exists: false },
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user