Fixing Pipelines Issues

This commit is contained in:
Silversthorn 2023-04-15 20:55:46 +02:00
parent 84a09ad9be
commit b5abc93a8e

View File

@ -1257,20 +1257,21 @@ class Helpers:
return lang + "-" + region
@staticmethod
def get_player_avatar(uuid):
def get_player_avatar(uuid_player):
mojang_response = requests.get(
f"https://sessionserver.mojang.com/session/minecraft/profile/{uuid}"
f"https://sessionserver.mojang.com/session/minecraft/profile/{uuid_player}",
timeout=10,
)
if mojang_response.status_code == 200:
uuid_profile = mojang_response.json()
profile_properties = uuid_profile["properties"]
for property in profile_properties:
if property["name"] == "textures":
decodedBytes = base64.b64decode(property["value"])
decodedStr = decodedBytes.decode("utf-8")
textureJson = json.loads(decodedStr)
skin_url = textureJson["textures"]["SKIN"]["url"]
skin_response = requests.get(skin_url, stream=True)
for prop in profile_properties:
if prop["name"] == "textures":
decoded_bytes = base64.b64decode(prop["value"])
decoded_str = decoded_bytes.decode("utf-8")
texture_json = json.loads(decoded_str)
skin_url = texture_json["textures"]["SKIN"]["url"]
skin_response = requests.get(skin_url, stream=True, timeout=10)
if skin_response.status_code == 200:
return base64.b64encode(skin_response.content)
else: