|
|
@ -1,10 +1,15 @@ |
|
|
|
import requests |
|
|
|
import requests |
|
|
|
|
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
version = "1.18.1" |
|
|
|
|
|
|
|
destPath = "../server/paper.jar" |
|
|
|
def get_paper(version, destination): |
|
|
|
|
|
|
|
print(f"Trying to fetch {version} into {destination}") |
|
|
|
|
|
|
|
|
|
|
|
base = "https://papermc.io/api/v2/projects/paper/versions" |
|
|
|
base = "https://papermc.io/api/v2/projects/paper/versions" |
|
|
|
r = requests.get(f"{base}/{version}") |
|
|
|
r = requests.get(f"{base}/{version}") |
|
|
|
|
|
|
|
if not r.ok: |
|
|
|
|
|
|
|
print(f"Cannot find version {version}, aborting.") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
build = max(r.json()['builds']) |
|
|
|
build = max(r.json()['builds']) |
|
|
|
r = requests.get(f"{base}/{version}/builds/{build}") |
|
|
|
r = requests.get(f"{base}/{version}/builds/{build}") |
|
|
@ -12,5 +17,21 @@ r = requests.get(f"{base}/{version}/builds/{build}") |
|
|
|
download = r.json()['downloads']['application']['name'] |
|
|
|
download = r.json()['downloads']['application']['name'] |
|
|
|
content = requests.get(f"{base}/{version}/builds/{build}/downloads/{download}").content |
|
|
|
content = requests.get(f"{base}/{version}/builds/{build}/downloads/{download}").content |
|
|
|
|
|
|
|
|
|
|
|
with open(destPath, "wb") as file: |
|
|
|
with open(destination, "wb") as jarFile: |
|
|
|
file.write(content) |
|
|
|
jarFile.write(content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv): |
|
|
|
|
|
|
|
if len(argv) == 1: |
|
|
|
|
|
|
|
print("No version defined!") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
version = argv[1] |
|
|
|
|
|
|
|
if len(argv) == 2: |
|
|
|
|
|
|
|
destination = "paper.jar" |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
destination = argv[2] |
|
|
|
|
|
|
|
get_paper(version, destination) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
main(sys.argv) |
|
|
|