From c427ddec8106ff71c68443572b3df477dbe5c8a3 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Sat, 10 May 2025 23:47:03 -0400 Subject: [PATCH] improve JSON data, restructure JSON, and add util scripts --- .gitignore | 2 + data_fill.js | 50 ++++++ list.json | 458 +++++++++++++++++++++++++++++---------------------- package.json | 3 + 4 files changed, 320 insertions(+), 193 deletions(-) create mode 100644 .gitignore create mode 100644 data_fill.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49e0fc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules +/package-lock.json \ No newline at end of file diff --git a/data_fill.js b/data_fill.js new file mode 100644 index 0000000..082c577 --- /dev/null +++ b/data_fill.js @@ -0,0 +1,50 @@ +import { readFile, writeFile } from "fs/promises"; + +function sorter(a, b) { + let ac = isNaN(a.count * 1) ? -1 : a.count; + let bc = isNaN(b.count * 1) ? -1 : b.count; + if (ac != bc) return bc - ac; + let h = a.type.localeCompare(b.type); + if (h != 0) return h; + return a.name.localeCompare(b.name); +} + +(async function () { + let jsoned = JSON.parse(await readFile('list.json', 'utf-8')); + + jsoned.sort(sorter); + + for (let j of jsoned) { + if (!j.link && j.type.startsWith('scratch')) { + let data = await fetch("https://api.scratch.mit.edu/search/projects?limit=16&offset=0&language=en&mode=popular&q=" + encodeURIComponent(j.name)); + let jason = await data.text(); + try { + jason = JSON.parse(jason); + } catch (err) { + jason = false; + } + if (jason && jason[0]) { + j.link = `https://scratch.mit.edu/projects/${jason[0].id}` + } + } + if (!j.creator && j.type.startsWith('scratch') && j.link) { + if (j.link.endsWith('/')) { + j.link = j.link.slice(0,-1); + } + let splitted = j.link.split('/'); + let data = await fetch("https://api.scratch.mit.edu/projects/" + splitted.pop()); + let jason = await data.text(); + try { + jason = JSON.parse(jason); + } catch (err) { + jason = false; + } + console.log(jason) + if (jason && jason.author) { + j.creator = jason.author.username + } + } + } + + await writeFile('list.json', JSON.stringify(jsoned, null, "\t")); +})() \ No newline at end of file diff --git a/list.json b/list.json index 8d9d73a..1693195 100644 --- a/list.json +++ b/list.json @@ -1,193 +1,265 @@ -{ - "gridremix": { - "type": "scratch/remix", - "count": 8164, - "link": "https://scratch.mit.edu/projects/1108657322" - }, - "gridsequel": { - "type": "scratch/comment", - "count": 2432, - "link": "https://scratch.mit.edu/projects/1171330726/" - }, - "Elimination War": { - "type": "scratch/remix", - "count": 2236, - "link": "https://scratch.mit.edu/projects/915524770/" - }, - "Tilepgrade!": { - "type": "scratch/remix", - "count": 1643, - "link": "https://scratch.mit.edu/projects/1134777535" - }, - "the dzje gridclose": { - "type": "scratch/remix", - "count": 1567, - "link": "https://scratch.mit.edu/projects/1123295780" - }, - "Gridchaos": { - "type": "scratch/remix", - "count": 1323, - "link": "https://scratch.mit.edu/projects/1138980333/" - }, - "Tiles III": { - "type": "scratch/remix", - "count": 734, - "link": "https://scratch.mit.edu/projects/704339952" - }, - "World grid": { - "type": "scratch/remix", - "count": 660, - "link": "https://scratch.mit.edu/projects/745582603" - }, - "Rectangle grid": { - "type": "scratch/remix", - "count": 642, - "link": "https://scratch.mit.edu/projects/921551663/" - }, - "Tiles V": { - "type": "scratch/remix", - "count": 626, - "link": "https://scratch.mit.edu/projects/944491062/" - }, - "gridnations": { - "type": "scratch/remix", - "count": 529, - "link": "https://scratch.mit.edu/projects/1115419396/" - }, - "2048TB 8x8": { - "type": "scratch/remix", - "count": 459, - "link": "https://scratch.mit.edu/projects/668102094/" - }, - "Tiles": { - "type": "scratch/remix", - "count": 458, - "link": "https://scratch.mit.edu/projects/456343869" - }, - "Tiles IV": { - "type": "scratch/remix", - "count": 412, - "link": "https://scratch.mit.edu/projects/632703259" - }, - "Elimination War III-ba": { - "type": "scratch/remix", - "count": 394, - "link": "https://scratch.mit.edu/projects/428529854/" - }, - "GridWars": { - "type": "scratch/comment", - "count": 368, - "link": "https://scratch.mit.edu/projects/1125080069" - }, - "Circle grid": { - "type": "scratch/remix", - "count": 339, - "link": "https://scratch.mit.edu/projects/888667879/" - }, - "London Grid": { - "type": "scratch/comment", - "count": 218, - "link": "https://scratch.mit.edu/projects/1139638835" - }, - "triangle grid": { - "type": "scratch/remix", - "count": 167, - "link": "https://scratch.mit.edu/projects/1117323412/" - }, - "TILEsequel": { - "type": "scratch/comment", - "count": 144, - "link": "https://scratch.mit.edu/projects/1158352413" - }, - "MGSTTBIB": { - "type": "scratch/comment", - "count": 144, - "link": "https://scratch.mit.edu/projects/1144455237" - }, - "Province Royale RP": { - "type": "scratch/comment", - "count": 119, - "link": "https://scratch.mit.edu/projects/1165553852" - }, - "gridsequel2": { - "type": "scratch/comment", - "count": 114, - "link": "https://scratch.mit.edu/projects/1136895805" - }, - "UK Map": { - "type": "scratch/comment", - "count": 97, - "link": "https://scratch.mit.edu/projects/1154428165" - }, - "sidoarjoland": { - "type": "scratch/comment", - "count": 72, - "link": "https://scratch.mit.edu/projects/1146021996" - }, - "GSBTNRERAI": { - "type": "scratch/comment", - "count": 59, - "link": "https://scratch.mit.edu/projects/1163966387" - }, - "the city gridclose": { - "type": "scratch/remix", - "count": 55, - "link": "https://scratch.mit.edu/projects/1137976112/" - }, - "gridsequel 6x6": { - "type": "scratch/comment", - "count": 48, - "link": "https://scratch.mit.edu/projects/1130728792" - }, - "GSBIH": { - "type": "scratch/comment", - "count": 47 - }, - "RHPMGG": { - "type": "scratch/comment", - "count": 38 - }, - "Number-grid": { - "type": "scratch/comment", - "count": 29, - "link": "https://scratch.mit.edu/projects/1151883415" - }, - "gridremix europe": { - "type": "scratch/remix", - "count": 26, - "link": "https://scratch.mit.edu/projects/1116212068/" - }, - "Tileland": { - "type": "scratch/comment", - "count": 12, - "link": "https://scratch.mit.edu/projects/1140335465" - }, - "Gridded": { - "type": "scratch/comment", - "count": 6, - "link": "https://scratch.mit.edu/projects/1157666430" - }, - "gridwars online": { - "type": "scratch/cloud", - "link": "https://scratch.mit.edu/projects/1151150233" - }, - "gridwar I": { - "type": "web/cloud", - "link": "https://gw.dervland.net/" - }, - "gridwar II": { - "type": "web/cloud" - }, - "gridsequel but tiles": { - "type": "scratch/comment", - "link": "https://scratch.mit.edu/projects/1149453901" - }, - "gridsequel but is HARDER": { - "type": "scratch/comment", - "link": "https://scratch.mit.edu/projects/1165885779" - }, - "Reborn's Poorly Made Grid Game": { - "type": "scratch/comment", - "link": "https://scratch.mit.edu/projects/1162274452" - } -} \ No newline at end of file +[ + { + "type": "scratch/remix", + "count": 8164, + "link": "https://scratch.mit.edu/projects/1108657322", + "name": "gridremix", + "creator": "RCUTB" + }, + { + "type": "scratch/comment", + "count": 2432, + "link": "https://scratch.mit.edu/projects/1171330726", + "name": "gridsequel", + "creator": "kamoz99" + }, + { + "type": "scratch/remix", + "count": 2236, + "link": "https://scratch.mit.edu/projects/915524770", + "name": "Elimination War", + "creator": "UnOfficalYousef" + }, + { + "type": "scratch/remix", + "count": 1643, + "link": "https://scratch.mit.edu/projects/1134777535", + "name": "Tilepgrade!", + "creator": "hooney1006" + }, + { + "type": "scratch/remix", + "count": 1567, + "link": "https://scratch.mit.edu/projects/1123295780", + "name": "the dzje gridclose" + }, + { + "type": "scratch/remix", + "count": 1323, + "link": "https://scratch.mit.edu/projects/1138980333", + "name": "Gridchaos", + "creator": "mark92330" + }, + { + "type": "scratch/remix", + "count": 734, + "link": "https://scratch.mit.edu/projects/704339952", + "name": "Tiles III", + "creator": "Redshell3" + }, + { + "type": "scratch/remix", + "count": 660, + "link": "https://scratch.mit.edu/projects/745582603", + "name": "World grid" + }, + { + "type": "scratch/remix", + "count": 642, + "link": "https://scratch.mit.edu/projects/921551663", + "name": "Rectangle grid", + "creator": "angelosonic3" + }, + { + "type": "scratch/remix", + "count": 626, + "link": "https://scratch.mit.edu/projects/944491062", + "name": "Tiles V", + "creator": "QuickCoderLongJumper" + }, + { + "type": "scratch/remix", + "count": 529, + "link": "https://scratch.mit.edu/projects/1115419396", + "name": "gridnations" + }, + { + "type": "scratch/remix", + "count": 459, + "link": "https://scratch.mit.edu/projects/668102094", + "name": "2048TB 8x8", + "creator": "HaydenAgain" + }, + { + "type": "scratch/remix", + "count": 458, + "link": "https://scratch.mit.edu/projects/456343869", + "name": "Tiles", + "creator": "vmax2019" + }, + { + "type": "scratch/remix", + "count": 412, + "link": "https://scratch.mit.edu/projects/632703259", + "name": "Tiles IV", + "creator": "player342521" + }, + { + "type": "scratch/remix", + "count": 394, + "link": "https://scratch.mit.edu/projects/428529854", + "name": "Elimination War III-ba", + "creator": "brodiejohnevil" + }, + { + "type": "scratch/comment", + "count": 368, + "link": "https://scratch.mit.edu/projects/1125080069", + "name": "GridWars", + "creator": "kamoz99" + }, + { + "type": "scratch/remix", + "count": 339, + "link": "https://scratch.mit.edu/projects/888667879", + "name": "Circle grid", + "creator": "Winicjusz2" + }, + { + "type": "scratch/comment", + "count": 218, + "link": "https://scratch.mit.edu/projects/1139638835", + "name": "London Grid", + "creator": "Rmgray1028" + }, + { + "type": "scratch/remix", + "count": 167, + "link": "https://scratch.mit.edu/projects/1117323412", + "name": "triangle grid" + }, + { + "type": "scratch/comment", + "count": 144, + "link": "https://scratch.mit.edu/projects/1144455237", + "name": "MGSTTBIB", + "creator": "mark92330" + }, + { + "type": "scratch/comment", + "count": 144, + "link": "https://scratch.mit.edu/projects/1158352413", + "name": "TILEsequel", + "creator": "mark92330" + }, + { + "type": "scratch/comment", + "count": 119, + "link": "https://scratch.mit.edu/projects/1165553852", + "name": "Province Royale RP", + "creator": "ckman0705" + }, + { + "type": "scratch/comment", + "count": 114, + "link": "https://scratch.mit.edu/projects/1136895805", + "name": "gridsequel2", + "creator": "SquashBuckets" + }, + { + "type": "scratch/comment", + "count": 97, + "link": "https://scratch.mit.edu/projects/1154428165", + "name": "UK Map", + "creator": "Rmgray1028" + }, + { + "type": "scratch/comment", + "count": 72, + "link": "https://scratch.mit.edu/projects/1146021996", + "name": "sidoarjoland", + "creator": "111thew" + }, + { + "type": "scratch/comment", + "count": 59, + "link": "https://scratch.mit.edu/projects/1163966387", + "name": "GSBTNRERAI", + "creator": "lincogames" + }, + { + "type": "scratch/remix", + "count": 55, + "link": "https://scratch.mit.edu/projects/1137976112", + "name": "the city gridclose", + "creator": "Hubert_stach78" + }, + { + "type": "scratch/comment", + "count": 48, + "link": "https://scratch.mit.edu/projects/1130728792", + "name": "gridsequel 6x6", + "creator": "RCUTB" + }, + { + "type": "scratch/comment", + "count": 47, + "name": "GSBIH" + }, + { + "type": "scratch/comment", + "count": 38, + "name": "RHPMGG" + }, + { + "type": "scratch/comment", + "count": 29, + "link": "https://scratch.mit.edu/projects/1151883415", + "name": "Number-grid", + "creator": "lincogames" + }, + { + "type": "scratch/remix", + "count": 26, + "link": "https://scratch.mit.edu/projects/1116212068", + "name": "gridremix europe", + "creator": "ToTheStars693" + }, + { + "type": "scratch/comment", + "count": 12, + "link": "https://scratch.mit.edu/projects/1140335465", + "name": "Tileland", + "creator": "kiaanmsaha15" + }, + { + "type": "scratch/comment", + "count": 6, + "link": "https://scratch.mit.edu/projects/1157666430", + "name": "Gridded", + "creator": "604sx" + }, + { + "type": "scratch/cloud", + "link": "https://scratch.mit.edu/projects/1151150233", + "name": "gridwars online", + "creator": "LD123Rises" + }, + { + "type": "scratch/comment", + "link": "https://scratch.mit.edu/projects/1165885779", + "name": "gridsequel but is HARDER", + "creator": "lincogames" + }, + { + "type": "scratch/comment", + "link": "https://scratch.mit.edu/projects/1149453901", + "name": "gridsequel but tiles", + "creator": "RCUTB" + }, + { + "type": "scratch/comment", + "link": "https://scratch.mit.edu/projects/1162274452", + "name": "Reborn's Poorly Made Grid Game", + "creator": "RebornHuman" + }, + { + "type": "web/cloud", + "name": "gridwar I" + }, + { + "type": "web/cloud", + "link": "https://gw.dervland.net/", + "name": "gridwar II" + } +] \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..96ae6e5 --- /dev/null +++ b/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} \ No newline at end of file