From 2d27fa1753f3d81d9627dca2ab8e84c5f6d0cf81 Mon Sep 17 00:00:00 2001 From: ewin Date: Fri, 1 May 2026 17:42:34 -0400 Subject: [PATCH] add desynth data update script --- bin/update-desynth-data | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 bin/update-desynth-data diff --git a/bin/update-desynth-data b/bin/update-desynth-data new file mode 100755 index 0000000..f9712c5 --- /dev/null +++ b/bin/update-desynth-data @@ -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)); +}