Created
May 13, 2019 09:08
-
-
Save ntoonio/198c14f5915fc9aafe54eba0fc1f4163 to your computer and use it in GitHub Desktop.
Minecraft server download script
This file contains 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
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