From dd38e39c4eeb42649e329016408b363df2c3a11a Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 22 Apr 2026 13:14:12 +0700 Subject: [PATCH] feat(loldle): weekly scraper for champion data from loldle.net Pulls canonical game fields (gender, positions, range_type, regions, release_date) from loldle.net's JS bundle and merges with ddragon championFull for display metadata (title, resource, genre, skinCount, image). Opens a PR weekly via GitHub Actions (Mon 06:00 UTC). --- .github/workflows/scrape-loldle-data.yml | 53 +++++++ package.json | 1 + scripts/scrape-loldle-data.js | 170 +++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 .github/workflows/scrape-loldle-data.yml create mode 100644 scripts/scrape-loldle-data.js diff --git a/.github/workflows/scrape-loldle-data.yml b/.github/workflows/scrape-loldle-data.yml new file mode 100644 index 0000000..cc4d318 --- /dev/null +++ b/.github/workflows/scrape-loldle-data.yml @@ -0,0 +1,53 @@ +name: scrape-loldle-data + +# Rebuilds src/modules/loldle/champions.json every Monday 06:00 UTC by +# scraping loldle.net's JS bundle + merging ddragon championFull. +# Opens a PR if the output changed. Manually triggerable from Actions tab. +# +# Note: the bundled data is shipped with the Worker — the change only takes +# effect after `npm run deploy` is run on the updated main branch. + +on: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + scrape: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: npm + + - run: npm ci + + - name: Scrape loldle.net + run: npm run scrape:loldle-data + + - name: Open PR if data changed + uses: peter-evans/create-pull-request@v7 + with: + branch: data/loldle-weekly-refresh + delete-branch: true + commit-message: "data: weekly loldle.net champion refresh" + title: "data: weekly loldle.net champion refresh" + body: | + Automated weekly refresh of `src/modules/loldle/champions.json` + from loldle.net + ddragon championFull. + + Fields sourced from loldle.net: `gender`, `attackType`, `lane`, + `region`, `releaseDate`. Display fields (`title`, `resource`, + `genre`, `skinCount`, `image`) come from ddragon. + + Review the diff, merge, then run `npm run deploy` to ship. + add-paths: | + src/modules/loldle/champions.json + src/modules/loldle/champions-data.js diff --git a/package.json b/package.json index 30f0e86..dc6155f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "build": "npm run build:loldle-data && npm run build:wordle-data", "build:loldle-data": "node scripts/build-loldle-data.js", "build:wordle-data": "node scripts/build-wordle-data.js", + "scrape:loldle-data": "node scripts/scrape-loldle-data.js", "deploy": "npm run build && wrangler deploy && npm run db:migrate && npm run register", "db:migrate": "node scripts/migrate.js", "register": "node --env-file-if-exists=.env.deploy scripts/register.js", diff --git a/scripts/scrape-loldle-data.js b/scripts/scrape-loldle-data.js new file mode 100644 index 0000000..bc3896d --- /dev/null +++ b/scripts/scrape-loldle-data.js @@ -0,0 +1,170 @@ +#!/usr/bin/env node +/** + * @file scrape-loldle-data — rebuilds src/modules/loldle/champions.json by + * scraping loldle.net for canonical game fields (gender, positions, + * range_type, regions, release_date) and merging with ddragon championFull + * for display fields (title, resource, genre tags, skin count, sprite image). + * + * Writes both champions.json (authoring format) and champions-data.js (ESM + * wrapper consumed by the bot). Replaces the hand-run build-loldle-data step. + * + * Source of truth — loldle.net embeds the full champion array in plaintext + * inside its JS bundle at `