From 44f2ae9e62053e9023bfd47c311b1de4a7890b61 Mon Sep 17 00:00:00 2001 From: Sacha Ligthert Date: Tue, 17 Jun 2025 20:00:40 +0200 Subject: [PATCH] Working version. Using latest of everything. --- README.md | 4 +++- fetcher.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 fetcher.py diff --git a/README.md b/README.md index 64bf289..d2a38a6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # minecraft_server_downloader -Grab the latest minecraft server.jar binary (to hand off to other tools) \ No newline at end of file +Grab the latest minecraft server.jar binary. + +Uses Python3 and the Requests library. diff --git a/fetcher.py b/fetcher.py new file mode 100755 index 0000000..aad7850 --- /dev/null +++ b/fetcher.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import requests + +# Fetch some manifests +url="https://launchermeta.mojang.com/mc/game/version_manifest.json" +stage1 = requests.get(url) +latest = stage1.json()["latest"]["release"] + +print("Latest version of Minecraft (Release):",latest) + +# Iterate through the json, grab the manifest of the newest version +for version in stage1.json()["versions"]: + if latest == version["id"]: + # print(version) + url = version["url"] + +# Grab it. Print. +stage2 = requests.get(url) +print("Downloading:",stage2.json()["downloads"]["server"]["url"]) + +print("Grabbing server.jar") +jarfile = requests.get(stage2.json()["downloads"]["server"]["url"]) +open("server.jar", "wb").write(jarfile.content) + +print("Done!")