Last active
January 6, 2024 20:47
-
-
Save ejm/fbc1dafe89f79b5828caec4241c6dbb0 to your computer and use it in GitHub Desktop.
Simple wrapper for Mojang's new Minecraft version manifest file
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
import requests | |
import json | |
MANIFEST_URL = "https://launchermeta.mojang.com/mc/game/version_manifest.json" | |
MANIFEST = requests.get(MANIFEST_URL).json() | |
def get_latest_version(type_): | |
if not type_ in ["snapshot", "release"]: | |
raise ValueError("Version type must be either snapshot or release") | |
return MANIFEST["latest"][type_] | |
def get_download_url(version, type_): | |
if not type_ in ["client", "server"]: | |
raise ValueError("Download type must be either client or server") | |
for ver in MANIFEST["versions"]: | |
if ver["id"] == version: | |
meta = requests.get(ver["url"]).json() | |
return meta["downloads"][type_]["url"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment