Created
June 23, 2020 02:28
-
-
Save ewpratten/e4d2671ee297bc931f1f32aedcc29f8a to your computer and use it in GitHub Desktop.
A little script for pulling people's mojang account history from their current username
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
import sys | |
import requests | |
from base64 import b64decode | |
import json | |
import time | |
if len(sys.argv ) != 2: | |
print("Usage: mcuserinfo.py <username>") | |
exit(0) | |
username = sys.argv[1] | |
userprofile = requests.get(f"https://api.mojang.com/users/profiles/minecraft/{username}").json() | |
uid = userprofile["id"] | |
username = userprofile["name"] | |
print(f"Full username: {username}") | |
print(f"User ID: {uid}") | |
history = requests.get(f"https://api.mojang.com/user/profiles/{uid}/names").json() | |
print("Name history:") | |
for name in history: | |
name = name["name"] | |
print(f" - {name}") | |
useraccount:dict = requests.post("https://api.mojang.com/profiles/minecraft", data=username).json() | |
isPremium = not useraccount.get("dmeo", False) | |
mojang = not useraccount.get("legacy", False) | |
print(f"Premium account: {isPremium}") | |
print(f"Mojang account: {mojang}") | |
skininfo = requests.get(f"https://sessionserver.mojang.com/session/minecraft/profile/{uid}").json() | |
if "error" in skininfo: | |
print("Pausing to reduce API load") | |
time.sleep(8) | |
skininfo = requests.get(f"https://sessionserver.mojang.com/session/minecraft/profile/{uid}").json() | |
texture = json.loads(b64decode([i for i in skininfo["properties"] if i["name"] == "textures"][0]["value"])) | |
cape = texture["textures"].get("CAPE", "") != "" | |
skin = texture["textures"]["SKIN"]["url"] | |
print(f"User skin: {skin}") | |
print(f"User has cape?: {cape}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment