diff options
author | Minteck <contact@minteck.org> | 2022-02-13 16:16:18 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-02-13 16:16:18 +0100 |
commit | 327119b4d1c2248b8a075cad3cd05ab92560e75d (patch) | |
tree | ce143399e74c120f7311e75490efd0defd9b58d8 /update/ponies/listgen.js | |
parent | ede8d0750f3f16e3ba5c3c3f716c98d267512b09 (diff) | |
download | ponyfind-327119b4d1c2248b8a075cad3cd05ab92560e75d.tar.gz ponyfind-327119b4d1c2248b8a075cad3cd05ab92560e75d.tar.bz2 ponyfind-327119b4d1c2248b8a075cad3cd05ab92560e75d.zip |
Feature: implements #8, voids #9
Diffstat (limited to 'update/ponies/listgen.js')
-rw-r--r-- | update/ponies/listgen.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/update/ponies/listgen.js b/update/ponies/listgen.js new file mode 100644 index 0000000..d9401f8 --- /dev/null +++ b/update/ponies/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 |