add desynth data update script

This commit is contained in:
ewin 2026-05-01 17:42:34 -04:00
parent 53d48912d0
commit 2d27fa1753
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc

28
bin/update-desynth-data Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env -S node --env-file-if-exists=.env
import {getMediawikiClient} from '../lib/config.js';
const mw = await getMediawikiClient();
const start = parseInt(process.env.START ?? '1', 10)
for (let bin = start; bin <= 50; bin += 1) {
// files are at e.g. https://gacha.infi.ovh/data/desynthesis/026000.json
const filename = `${String(bin).padStart(3, '0')}000.json`;
const url = `https://gacha.infi.ovh/data/desynthesis/${filename}`;
const targetPage = `Module:Desynthesis/${filename}`;
console.log('Bin', bin, url, '->', targetPage);
// download
const data = await fetch(`https://gacha.infi.ovh/data/desynthesis/${filename}`).then(response => response.json());
// upload
try {
await mw.editPage(`Module:Desynthesis/${filename}`, JSON.stringify(data), 'update desynth data');
console.log('Written.');
} catch (error) {
// terrible
throw error;
}
// self-ratelimiting - 6 requests per minute should be enough for anyone :clueless:
await new Promise(resolve => setTimeout(resolve, 10000));
}