Last active
May 15, 2020 15:29
-
-
Save unixfox/c728468c132b66d5fac0d74b1589da5a to your computer and use it in GitHub Desktop.
get skins of the minecraft players that liked a server on namemc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const got = require('got'); | |
const fs = require("fs"); | |
const Queue = require('better-queue'); | |
const prompts = require('prompts'); | |
const APIs = Array("https://crafatar.com/skins/", "https://visage.surgeplay.com/skin/", "https://crafatar.com/skins/"); | |
(async () => { | |
const response = await prompts({ | |
type: 'text', | |
name: 'value', | |
message: 'Quel serveur je dois récupérer les skins des gens qui ont like sur NameMC ? (serveur valide!)' | |
}); | |
q = new Queue(function (UUIDs, cb) { | |
this.progressTask(2, 30, 100, "copying") | |
UUIDs.forEach(UUID => { | |
//console.log(UUID); | |
got(APIs[Math.floor(Math.random() * APIs.length)] + UUID, { resolveBodyOnly: true, responseType: 'buffer', throwHttpErrors: false }).then((skin) => { | |
fs.writeFile("skins-" + response.value + "/" + UUID + ".png", skin, (err) => { | |
if (err) throw err; | |
cb(null); | |
}); | |
}); | |
}); | |
}, { batchSize: 5 }); | |
console.log(response.value + "? OK! Let's go"); | |
const likesUUID = await got('https://api.namemc.com/server/' + response.value + '/likes', { resolveBodyOnly: true, responseType: 'json' }); | |
if (likesUUID === []) { | |
console.log("mmh le serveur n'existe pas... try again?"); | |
} | |
else { | |
if (!fs.existsSync("skins-" + response.value)) { | |
fs.mkdirSync("skins-" + response.value); | |
} | |
likesUUID.forEach(UUID => { | |
q.push(UUID) | |
}); | |
} | |
setInterval(function () { | |
const stats = q.getStats(); | |
console.log("J'ai récupéré " + stats.total + " skins sur " + likesUUID.length + "!" ); | |
}, 30000); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
avec une réussite de " + stats.successRate + { | |
"name": "likes-skin-namemc", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"better-queue": "^3.8.10", | |
"got": "^11.1.3", | |
"prompts": "^2.3.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment