Skip to content

Instantly share code, notes, and snippets.

@ntoonio
Created May 13, 2019 09:08
Show Gist options
  • Save ntoonio/198c14f5915fc9aafe54eba0fc1f4163 to your computer and use it in GitHub Desktop.
Save ntoonio/198c14f5915fc9aafe54eba0fc1f4163 to your computer and use it in GitHub Desktop.
Minecraft server download script
VERSION_MANIFEST_URL = "https://launchermeta.mojang.com/mc/game/version_manifest.json"
import json
import requests
import argparse
import urllib.request
rManifest = requests.get(VERSION_MANIFEST_URL)
manifest = rManifest.json()
latestVersion = manifest["latest"]["release"]
latestSnapshotVersion = manifest["latest"]["snapshot"]
a = argparse.ArgumentParser()
a.add_argument("-v", "--version", help="Version, default to latest", default=latestVersion)
a.add_argument("-s", "--snapshot", help="Use the latest snapshot", const=latestSnapshotVersion, dest="version", action="store_const")
args = a.parse_args()
version = args.version
versionURL = None
for v in manifest["versions"]:
if v["id"] == version:
versionURL = v["url"]
break
if versionURL == None:
print("Can't find version " + version)
else:
rVersionManifest = requests.get(versionURL)
versionManifest = rVersionManifest.json()
serverDownloadURL = versionManifest["downloads"]["server"]["url"]
print("Downloading server version " + version + "...")
urllib.request.urlretrieve(serverDownloadURL, ".\\server.jar")
print("Done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment