importrequestsimportjsonimportbase64importreimporturllib.requestdefget_minecraft_skin():print("LEl_FENG blog.xpdbk.com Minecraft skin uuid crawler 1.0 <press enter to skip>")input()filename=input("The name of the skin image after saving: ")username=input("Please enter the genuine player username: ")# Check whether the username complies with Minecraft naming rulesifnotre.match("^[a-zA-Z0-9_]{3,16}$",username):print("Username does not comply with Minecraft naming rules")returntry:response=requests.get(f"https://api.mojang.com/users/profiles/minecraft/{username}")response.raise_for_status()exceptrequests.exceptions.HTTPErroraserrh:print("Http Error:",errh)returnexceptrequests.exceptions.ConnectionErroraserrc:print("Error Connecting:",errc)returnexceptrequests.exceptions.Timeoutaserrt:print("Timeout Error:",errt)returnexceptrequests.exceptions.RequestExceptionaserr:print("Something went wrong",err)returndata=response.json()uuid=data["id"]print(f"The UUID is {uuid}, do you want to get the skin? Press Enter to continue")input()try:response=requests.get(f"https://sessionserver.mojang.com/session/minecraft/profile/{uuid}")response.raise_for_status()exceptrequests.exceptions.HTTPErroraserrh:print("Http Error:",errh)returnexceptrequests.exceptions.ConnectionErroraserrc:print("Error Connecting:",errc)returnexceptrequests.exceptions.Timeoutaserrt:print("Timeout Error:",errt)returnexceptrequests.exceptions.RequestExceptionaserr:print("Something went wrong",err)returndata=response.json()base64_data=data["properties"][0]["value"]decoded_data=base64.b64decode(base64_data).decode('utf-8')skin_data=json.loads(decoded_data)skin_url=skin_data["textures"]["SKIN"]["url"]try:urllib.request.urlretrieve(skin_url,f"{filename}.webp")exceptExceptionase:print(f"Error occurred while saving the image: {e}")returnprint("Skin has been saved")if__name__=="__main__":get_minecraft_skin()