add desynth data update script
This commit is contained in:
parent
53d48912d0
commit
2d27fa1753
1 changed files with 28 additions and 0 deletions
28
bin/update-desynth-data
Executable file
28
bin/update-desynth-data
Executable 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));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue