Fix pet loading for most pets
Sigh, I guess xmlrpc was deleted? Back to the method that doesn't work for pets with leading digits in their names, sobbe Dice has a neat idea for how to work around that, but I'm not sure how to fit it in our architecture, let's take a look!
This commit is contained in:
parent
85d68f68e1
commit
80428e9834
2 changed files with 11 additions and 13 deletions
|
@ -56,8 +56,7 @@
|
|||
"sharp": "^0.29.2",
|
||||
"simple-markdown": "^0.7.2",
|
||||
"tweenjs": "^1.0.2",
|
||||
"typescript": "^4.4.4",
|
||||
"xmlrpc": "^1.3.2"
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
import util from "util";
|
||||
import fetch from "node-fetch";
|
||||
import xmlrpc from "xmlrpc";
|
||||
|
||||
const neopetsXmlrpcClient = xmlrpc.createSecureClient({
|
||||
host: "www.neopets.com",
|
||||
path: "/amfphp/xmlrpc.php",
|
||||
});
|
||||
const neopetsXmlrpcCall = util
|
||||
.promisify(neopetsXmlrpcClient.methodCall)
|
||||
.bind(neopetsXmlrpcClient);
|
||||
async function neopetsAmfphpCall(methodName, args) {
|
||||
const url =
|
||||
"https://www.neopets.com/amfphp/json.php/" +
|
||||
encodeURIComponent(methodName) +
|
||||
"/" +
|
||||
args.map(encodeURIComponent).join("/");
|
||||
return await fetch(url).then((res) => res.json());
|
||||
}
|
||||
|
||||
export async function loadPetMetaData(petName) {
|
||||
const response = await neopetsXmlrpcCall("PetService.getPet", [petName]);
|
||||
const response = await neopetsAmfphpCall("PetService.getPet", [petName]);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function loadCustomPetData(petName) {
|
||||
try {
|
||||
const response = await neopetsXmlrpcCall("CustomPetService.getViewerData", [
|
||||
const response = await neopetsAmfphpCall("CustomPetService.getViewerData", [
|
||||
petName,
|
||||
]);
|
||||
return response;
|
||||
|
|
Loading…
Reference in a new issue