aboutsummaryrefslogtreecommitdiff
path: root/update
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-14 14:37:21 +0100
committerMinteck <contact@minteck.org>2022-01-14 14:37:21 +0100
commit81884db115f3f6a5d4e968fb77cc050cadb1a05e (patch)
tree040d5448c46a432facef26d4f9f9fc2823090466 /update
parent541633055c76a0c002fb8509f106f4b449e21207 (diff)
downloadponyfind-81884db115f3f6a5d4e968fb77cc050cadb1a05e.tar.gz
ponyfind-81884db115f3f6a5d4e968fb77cc050cadb1a05e.tar.bz2
ponyfind-81884db115f3f6a5d4e968fb77cc050cadb1a05e.zip
v8
Diffstat (limited to 'update')
-rw-r--r--update/infobox.js15
-rw-r--r--update/parse.js3
2 files changed, 18 insertions, 0 deletions
diff --git a/update/infobox.js b/update/infobox.js
index e27177e..b94080c 100644
--- a/update/infobox.js
+++ b/update/infobox.js
@@ -12,6 +12,7 @@ console.log("Gathering infobox for each page...");
try {
let data = (await axios.get("https://mlp.fandom.com/api.php?action=query&prop=revisions&titles=" + page.name + "&rvslots=*&rvprop=content&formatversion=2&format=json")).data;
let mwextracts = (await axios.get("https://mlp.fandom.com/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&exintro&titles=" + encodeURI(page.name) + "&redirects=")).data;
+ let mwtext = (await axios.get("https://mlp.fandom.com/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&titles=" + encodeURI(page.name) + "&redirects=")).data;
let extracts = "";
try {
sentences = mwextracts.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.replace(/(.*)\n(.*)/, "$2").replace(/(.*)\n\n(.*)/gm, "$2").replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
@@ -47,6 +48,20 @@ console.log("Gathering infobox for each page...");
} else {
console.log("No results found, ignoring name");
}
+ try {
+ if (mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("friendship is magic")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("fim")
+ ) {
+ infoboxes[page.name]["_gen"] = 4;
+ } else if (mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("a new generation")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("ang")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("ang")
+ ) {
+ infoboxes[page.name]["_gen"] = 5;
+ } else {
+ infoboxes[page.name]["_gen"] = -1;
+ }
+ } catch(e) {}
} catch (e) {
console.error(e);
}
diff --git a/update/parse.js b/update/parse.js
index 088e8d2..ebcd9e3 100644
--- a/update/parse.js
+++ b/update/parse.js
@@ -13,6 +13,7 @@ let ponies = {};
names: [title],
extract: "",
extract_fr: "",
+ generation: -1,
color: "000000",
image: "https://example.com",
kind: "Pony",
@@ -22,6 +23,8 @@ let ponies = {};
mark: "https://example.com"
}
+ if (typeof box._gen !== "undefined") data.generation = box._gen;
+
if (typeof box.name2 !== "undefined") data.names.push(box.name2.replace(/<!--[\s\S]*?-->/g, ""));
if (typeof box.name3 !== "undefined") data.names.push(box.name3.replace(/<!--[\s\S]*?-->/g, ""));
if (typeof box.name4 !== "undefined") data.names.push(box.name4.replace(/<!--[\s\S]*?-->/g, ""));