mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-11 16:58:25 +03:00
i accidentally the eslint
This commit is contained in:
@@ -18,74 +18,74 @@ program.parse(process.argv);
|
||||
const options = program.opts();
|
||||
|
||||
async function GetIIDXSongs() {
|
||||
const allSongs = [];
|
||||
const allSongs = [];
|
||||
|
||||
let url = `https://${options.url}/api/v1/iidx/27/music/`;
|
||||
let url = `https://${options.url}/api/v1/iidx/27/music/`;
|
||||
|
||||
let moreData = true;
|
||||
while (moreData) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const songs = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.bearer}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
let moreData = true;
|
||||
while (moreData) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const songs = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.bearer}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
if (songs._links._next) {
|
||||
url = songs._links._next;
|
||||
} else {
|
||||
moreData = false;
|
||||
}
|
||||
if (songs._links._next) {
|
||||
url = songs._links._next;
|
||||
} else {
|
||||
moreData = false;
|
||||
}
|
||||
|
||||
allSongs.push(...songs._items);
|
||||
}
|
||||
allSongs.push(...songs._items);
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, "./songs.json"), JSON.stringify(allSongs));
|
||||
fs.writeFileSync(path.join(__dirname, "./songs.json"), JSON.stringify(allSongs));
|
||||
}
|
||||
|
||||
async function GetCharts() {
|
||||
const 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");
|
||||
logger.info("Parsed songs.json");
|
||||
|
||||
const allCharts: any[] = [];
|
||||
const failed: any[] = [];
|
||||
const allCharts: any[] = [];
|
||||
const failed: any[] = [];
|
||||
|
||||
async function DoStuff(song: any) {
|
||||
try {
|
||||
logger.info(
|
||||
`Starting Request https://${options.url}/api/v1/iidx/27/charts/?music_id=${song._id}&omnimix=true.`
|
||||
);
|
||||
async function DoStuff(song: any) {
|
||||
try {
|
||||
logger.info(
|
||||
`Starting Request https://${options.url}/api/v1/iidx/27/charts/?music_id=${song._id}&omnimix=true.`
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const charts = await fetch(
|
||||
`https://${options.url}/api/v1/iidx/27/charts/?music_id=${song._id}&omnimix=true`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.bearer}`,
|
||||
},
|
||||
}
|
||||
).then((r) => r.json());
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const charts = await fetch(
|
||||
`https://${options.url}/api/v1/iidx/27/charts/?music_id=${song._id}&omnimix=true`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.bearer}`,
|
||||
},
|
||||
}
|
||||
).then((r) => r.json());
|
||||
|
||||
logger.info(`Parsed: ${charts._related.music[0].title}`);
|
||||
logger.info(`Parsed: ${charts._related.music[0].title}`);
|
||||
|
||||
allCharts.push(charts);
|
||||
} catch (err) {
|
||||
logger.error(song);
|
||||
logger.error(err);
|
||||
failed.push(err);
|
||||
}
|
||||
}
|
||||
allCharts.push(charts);
|
||||
} catch (err) {
|
||||
logger.error(song);
|
||||
logger.error(err);
|
||||
failed.push(err);
|
||||
}
|
||||
}
|
||||
|
||||
const promises = songs.map((s: any) => DoStuff(s));
|
||||
const promises = songs.map((s: any) => DoStuff(s));
|
||||
|
||||
await Promise.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, "./charts.json"), JSON.stringify(allCharts));
|
||||
fs.writeFileSync(path.join(__dirname, "./charts.json"), JSON.stringify(allCharts));
|
||||
|
||||
logger.info(failed);
|
||||
logger.info(failed);
|
||||
|
||||
logger.info("done?");
|
||||
logger.info("done?");
|
||||
}
|
||||
|
||||
GetCharts();
|
||||
|
||||
@@ -10,77 +10,77 @@ import { FindChartWithPTDFVersion } from "../../src/common/database-lookup/chart
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function MergeIDs() {
|
||||
const 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) {
|
||||
const songTitle = chartData._related.music[0].title;
|
||||
for (const chartData of charts) {
|
||||
const songTitle = chartData._related.music[0].title;
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const song = await FindSongOnTitle("iidx", songTitle);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const song = await FindSongOnTitle("iidx", songTitle);
|
||||
|
||||
if (!song) {
|
||||
logger.error(`Could not resolve ${songTitle}?`);
|
||||
continue;
|
||||
}
|
||||
if (!song) {
|
||||
logger.error(`Could not resolve ${songTitle}?`);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const chart of chartData._items) {
|
||||
const playtype: "SP" | "DP" = chart.play_style === "DOUBLE" ? "DP" : "SP";
|
||||
let difficulty = chart.difficulty === "BLACK" ? "LEGGENDARIA" : chart.difficulty;
|
||||
const version = "27-omni";
|
||||
for (const chart of chartData._items) {
|
||||
const playtype: "SP" | "DP" = chart.play_style === "DOUBLE" ? "DP" : "SP";
|
||||
let difficulty = chart.difficulty === "BLACK" ? "LEGGENDARIA" : chart.difficulty;
|
||||
const version = "27-omni";
|
||||
|
||||
// yeah this fails for wacky playtype mismatches -- i don't care.
|
||||
if (
|
||||
["ミッドナイト堕天使", "Y&Co. is dead or alive", "State Of The Art"].includes(
|
||||
songTitle
|
||||
) &&
|
||||
difficulty === "LEGGENDARIA"
|
||||
) {
|
||||
difficulty = "ANOTHER";
|
||||
}
|
||||
// yeah this fails for wacky playtype mismatches -- i don't care.
|
||||
if (
|
||||
["ミッドナイト堕天使", "Y&Co. is dead or alive", "State Of The Art"].includes(
|
||||
songTitle
|
||||
) &&
|
||||
difficulty === "LEGGENDARIA"
|
||||
) {
|
||||
difficulty = "ANOTHER";
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const tachiChart = await FindChartWithPTDFVersion(
|
||||
"iidx",
|
||||
song.id,
|
||||
playtype,
|
||||
difficulty,
|
||||
version
|
||||
);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const tachiChart = await FindChartWithPTDFVersion(
|
||||
"iidx",
|
||||
song.id,
|
||||
playtype,
|
||||
difficulty,
|
||||
version
|
||||
);
|
||||
|
||||
if (!tachiChart) {
|
||||
logger.error(
|
||||
`Could not find chart ${songTitle} ${playtype} ${difficulty} ${version}.`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (!tachiChart) {
|
||||
logger.error(
|
||||
`Could not find chart ${songTitle} ${playtype} ${difficulty} ${version}.`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await (
|
||||
db.charts.iidx as unknown as ICollection<ChartDocument<"iidx:SP" | "iidx:DP">>
|
||||
).update(
|
||||
{
|
||||
_id: tachiChart._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
"data.arcChartID": chart._id,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await (
|
||||
db.charts.iidx as unknown as ICollection<ChartDocument<"iidx:SP" | "iidx:DP">>
|
||||
).update(
|
||||
{
|
||||
_id: tachiChart._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
"data.arcChartID": chart._id,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const r = await db.charts.iidx.update(
|
||||
{
|
||||
"data.arcChartID": { $exists: false },
|
||||
},
|
||||
{ $set: { "data.arcChartID": null } },
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
);
|
||||
const r = await db.charts.iidx.update(
|
||||
{
|
||||
"data.arcChartID": { $exists: false },
|
||||
},
|
||||
{ $set: { "data.arcChartID": null } },
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
);
|
||||
|
||||
logger.info("done.", { r });
|
||||
logger.info("done.", { r });
|
||||
}
|
||||
|
||||
MergeIDs();
|
||||
|
||||
Reference in New Issue
Block a user