Created
April 24, 2016 19:30
-
-
Save KillerGoldFisch/c9aebc9719204dfe71d29bab08fef3f5 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python | |
| from mcstatus import MinecraftServer | |
| import json | |
| import urllib2 | |
| def processNames(names): | |
| url = "https://eu.mc-api.net/v3/uuid/" + ",".join(names) + "/json" | |
| tmp = json.loads(get(url)) | |
| ret = [] | |
| for player in tmp["success"]: | |
| ret.append(dict(name=player['name'], uuid=player['uuid'])) | |
| return ret | |
| def get(url): | |
| return urllib2.urlopen(url).read() | |
| def main(): | |
| import sys | |
| host = sys.argv[1] | |
| server = MinecraftServer(host) | |
| print json.dumps(processNames(server.query().players.names), indent=4) | |
| sys.exit(0) | |
| if __name__=="__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment