aboutsummaryrefslogtreecommitdiff
path: root/update/listgen.js
diff options
context:
space:
mode:
Diffstat (limited to 'update/listgen.js')
-rw-r--r--update/listgen.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/update/listgen.js b/update/listgen.js
new file mode 100644
index 0000000..d9401f8
--- /dev/null
+++ b/update/listgen.js
@@ -0,0 +1,24 @@
+const axios = require("axios");
+const fs = require("fs");
+
+if (fs.existsSync("./data")) fs.rmSync("./data", { recursive: true });
+fs.mkdirSync("./data");
+
+(async () => {
+ async function getCategory(category) {
+ console.log("Category:" + category);
+ let cat = (await axios.get("https://mlp.fandom.com/api.php?action=query&generator=categorymembers&gcmtitle=Category:" + encodeURI(category) + "&prop=categories&cllimit=max&gcmlimit=max&format=json")).data;
+
+ return Object.keys(cat.query.pages).map(k => cat.query.pages[k].title).filter(k => !k.startsWith("List") && !k.includes("EG") && !k.toLowerCase().includes("ponies") && !k.includes(" and ") && !k.includes("(") && !k.includes("family"));
+ }
+
+ let list = [...new Set([
+ ...(await getCategory("Pegasus ponies")),
+ ...(await getCategory("Alicorn ponies")),
+ ...(await getCategory("Earth ponies")),
+ ...(await getCategory("Unicorn ponies")),
+ ...(await getCategory("Main characters")),
+ ...(await getCategory("Dragons")),
+ ])];
+ fs.writeFileSync("./data/list.json", JSON.stringify(list, null, 4))
+})() \ No newline at end of file