aboutsummaryrefslogtreecommitdiff
path: root/update
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-09 13:04:14 +0100
committerMinteck <contact@minteck.org>2022-01-09 13:04:14 +0100
commitdc65563df84d80bcc0970febef6a5f9a7759bdcb (patch)
tree683adf13430bce48c23e6928a3a2eb0b5614094a /update
parentad5950fb36d71b0f522ac3dab80983212cafee44 (diff)
downloadponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.tar.gz
ponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.tar.bz2
ponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.zip
smol update
Diffstat (limited to 'update')
-rw-r--r--update/infobox.js2
-rw-r--r--update/parse.js28
2 files changed, 15 insertions, 15 deletions
diff --git a/update/infobox.js b/update/infobox.js
index b9d2591..faaf943 100644
--- a/update/infobox.js
+++ b/update/infobox.js
@@ -14,7 +14,7 @@ console.log("Gathering infobox for each page...");
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 extracts = "";
try {
- extracts = mwextracts.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.replace(/(.*)\n\n(.*)/gm, "$2").replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|")[0];
+ extracts = 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("|")[0];
} catch (e) {
extracts = "";
}
diff --git a/update/parse.js b/update/parse.js
index 6f4ee3a..217cfd8 100644
--- a/update/parse.js
+++ b/update/parse.js
@@ -22,13 +22,13 @@ let ponies = {};
mark: "https://example.com"
}
- if (typeof box.name2 !== "undefined") data.names.push(box.name2);
- if (typeof box.name3 !== "undefined") data.names.push(box.name3);
- if (typeof box.name4 !== "undefined") data.names.push(box.name4);
- if (typeof box.name5 !== "undefined") data.names.push(box.name5);
+ 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, ""));
+ if (typeof box.name5 !== "undefined") data.names.push(box.name5.replace(/<!--[\s\S]*?-->/g, ""));
if (typeof box.nicknames !== "undefined") {
- box.nicknames.split(",").filter(e => !e.match(/[^a-zA-Z0-9-_ ]/gm)).forEach((e, i) => {
+ box.nicknames.replace(/<!--[\s\S]*?-->/g, "").split(",").filter(e => !e.match(/[^a-zA-Z0-9-_ ]/gm)).forEach((e, i) => {
data.names.push(e.trim());
});
}
@@ -37,7 +37,7 @@ let ponies = {};
kp = box.kind.replace(/<!--[\s\S]*?-->/g, "").replace(/[^a-zA-Z0-9-_ ]/gm, "").split(" ")[0];
data.kind = kp.substr(kp.replace(/([A-Z])([a-z0-9]*)$/g, "").length);
}
- if (typeof box.sex !== "undefined") data.sex = box.sex.startsWith("F") ? "F" : "M";
+ if (typeof box.sex !== "undefined") data.sex = box.sex.replace(/<!--[\s\S]*?-->/g, "").trim().startsWith("F") ? "F" : "M";
if (typeof box._extract !== "undefined") {
data.extract = box._extract;
}
@@ -46,29 +46,29 @@ let ponies = {};
} else {
data.extract_fr = data.extract;
}
- if (typeof box.coat !== "undefined") data.color = box.coat.replace(/\[(.*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1");
- if (typeof box.main !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.main);
- if (typeof box.main1 !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.main1);
- if (typeof box.image !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.image);
+ if (typeof box.coat !== "undefined") data.color = box.coat.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[(.*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1");
+ if (typeof box.main !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.main.replace(/<!--[\s\S]*?-->/g, "").trim());
+ if (typeof box.main1 !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.main1.replace(/<!--[\s\S]*?-->/g, "").trim());
+ if (typeof box.image !== "undefined") data.image = "https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.image.replace(/<!--[\s\S]*?-->/g, "").trim());
if (typeof box["cutie mark"] !== "undefined") {
try {
- data.markimg = box["cutie mark"].split("[[File:")[1].split("|")[0];
+ data.markimg = box["cutie mark"].replace(/<!--[\s\S]*?-->/g, "").trim().split("[[File:")[1].split("|")[0];
} catch (e) {
- data.markimg = box["cutie mark"].split("[[File:")[0].split("|")[0];
+ data.markimg = box["cutie mark"].replace(/<!--[\s\S]*?-->/g, "").trim().split("[[File:")[0].split("|")[0];
}
data.mark = "https://mlp.fandom.com/Special:Redirect/file/" + encodeURI(data.markimg) + "?width=128";
}
if (typeof box.occupation !== "undefined") {
occupations = [];
- box.occupation/*.replace(/\[\[(.*)_(.*)\]\]|\[\[(.*)\|(.*)\]\]|\[\[(.*)\]\]/gm, "$2$4$5")*/.replace(/\|/gm, "_").replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").replace(/( \|| \| | \| )/gm, "|").split("|").forEach((e) => {
+ box.occupation/*.replace(/\[\[(.*)_(.*)\]\]|\[\[(.*)\|(.*)\]\]|\[\[(.*)\]\]/gm, "$2$4$5")*/.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\|/gm, "_").replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").replace(/( \|| \| | \| )/gm, "|").split("|").forEach((e) => {
occupations.push(e.trim().replace(/[\[\]]/gm, "").replace(/<(.*)>/gm, "").replace(/([a-zA-Z0-9 \-_,.'"]*)_([a-zA-Z0-9 \-_,.'"]*)/gm, "$2"));
})
data.occupation = occupations;
}
if (typeof box.residence !== "undefined") {
residences = [];
- box.residence/*.replace(/\[\[(.*)_(.*)\]\]|\[\[(.*)\|(.*)\]\]|\[\[(.*)\]\]/gm, "$2$4$5")*/.replace(/\|/gm, "_").replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").replace(/( \|| \| | \| )/gm, "|").split("|").forEach((e) => {
+ box.residence/*.replace(/\[\[(.*)_(.*)\]\]|\[\[(.*)\|(.*)\]\]|\[\[(.*)\]\]/gm, "$2$4$5")*/.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\|/gm, "_").replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").replace(/( \|| \| | \| )/gm, "|").split("|").forEach((e) => {
residences.push(e.trim().replace(/[\[\]]/gm, "").replace(/<(.*)>/gm, "").replace(/([a-zA-Z0-9 \-_,.'"]*)_([a-zA-Z0-9 \-_,.'"]*)/gm, "$2"));
})
data.residence = residences;