Last active
January 2, 2022 14:10
-
-
Save Vftdan/a59ee14298070fcf3b2a8363ce7879a6 to your computer and use it in GitHub Desktop.
Scripts for fetching minecraft skins
This file contains 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
#! /bin/bash | |
curl `mcskinurl $1` --create-dirs -o ~/mcskins/$1.png |
This file contains 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
#! /usr/bin/nodejs | |
var https = require('https'); | |
function atob(a) { | |
return new Buffer(a, 'base64').toString('binary'); | |
} | |
function get(url, cb) { | |
var h = url.match(/^https/i) ? https : http; | |
h.get(url, (r) => { | |
var d = ''; | |
r.on('data', (c) => {d += c}); | |
r.on('end', function() { | |
cb(d); | |
}); | |
}).on("error", (e) => { | |
console.error(e); | |
}); | |
} | |
var nick = process.argv[2]; | |
get("https://api.mojang.com/users/profiles/minecraft/" + encodeURIComponent(nick), (p) => { | |
p = JSON.parse(p); | |
if("error" in p) { | |
console.error(p.error + ": " + p.errorMessage); | |
} else { | |
var id = p.id; | |
get("https://sessionserver.mojang.com/session/minecraft/profile/" + id, (s) => { | |
s = JSON.parse(s); | |
var prop = s.properties, url, i, cp; | |
for(i in prop) { | |
if(prop[i].name != "textures") continue; | |
cp = JSON.parse(atob(prop[i].value)); | |
url = cp.textures.SKIN.url; | |
} | |
console.log(url); | |
}); | |
} | |
}); |
This file contains 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
$ mcskinurl <nickname> | |
Prints url of skin | |
Requires NodeJS | |
$ mcskin <nickname> | |
Saves skin to ~/mcskins/<nickname>.png | |
Requires curl, mcskinurl in path; bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment