Skip to content

Instantly share code, notes, and snippets.

@Cubixmeister
Last active January 31, 2018 00:56
Show Gist options
  • Save Cubixmeister/0aec860f059df1b801e0e1c8545793be to your computer and use it in GitHub Desktop.
Save Cubixmeister/0aec860f059df1b801e0e1c8545793be to your computer and use it in GitHub Desktop.
Download latest Minecraft server binary script
import requests, shutil
binary_type = 'server' # or 'client'
version_type = 'release' # or 'snapshot'
manifest = requests.get("https://launchermeta.mojang.com/mc/game/version_manifest.json").json()
version_id = manifest['latest'][version_type]
print "Latest {}: {}".format(version_type, version_id)
try:
version_url = [i['url'] for i in manifest['versions'] if i['id'] == version_id][0]
except IndexError:
raise RuntimeException("version {} not found!".format(version_id))
version = requests.get(version_url).json()
jar_url = version['downloads'][binary_type]['url']
output_fn = "minecraft_{}_{}.jar".format(version_id, binary_type)
print "Downloading {} from {}".format(output_fn, jar_url)
r = requests.get(jar_url, stream=True)
r.raise_for_status()
with open(output_fn, 'wb') as f:
shutil.copyfileobj(r.raw, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment