Automatically download the newest daily build

Zitim

New member
I'm getting the same error with the latest builds. What is the last version that works with standard Java (version 8 update 311)?
 

fronobulax

Developer
Staff member
I'm getting the same error with the latest builds. What is the last version that works with standard Java (version 8 update 311)?


Whether the downloader works for you or not, the jar you download will need something newer than Java 8.
 

Zitim

New member
Huh. OK. I had no idea Oracle's Java was so out of date. Funny how their auto updates never mention that. I hadn't downloaded a new Mafia JAR since September, so I didn't encounter the incompatibility until now. Thanks for the heads up.
 

hesuchia

Member
My old Python 3 auto-update script broke down yesterday due to some issue on ci.kolmafia.us. Now that KoLmafia lives on GitHub, it made sense to tweak the script to download from GitHub instead:

SNIP

For some reason github or mafia decided to list the dmg as asset 0 in the JSON files so running this downloads the dmg instead of the jar. Tweaked the code a bit to make sure the filename has .jar in it. Might break if for some reason the asset doesn't have it, I'm very noob at programming, but:

Python:
#!/usr/bin/env python
"""Updates KolMafia"""
import json
import pathlib
import sys
import urllib.request


def main():
    """Main entry point"""
    RELEASES_URL = "https://api.github.com/repos/kolmafia/kolmafia/releases"

    print(f"Visiting {RELEASES_URL}")
    with urllib.request.urlopen(RELEASES_URL) as response:
        body = response.read().decode("ISO-8859-1")
    json_data = json.loads(body)
    json_index = 0
    while json_index < len(json_data[0]["assets"]):
        if ".jar" in json_data[0]["assets"][json_index]["name"]:
            break
        else:
            json_index += 1
            continue
    first_asset = json_data[0]["assets"][json_index]
    jar_name = first_asset["name"]
    jar_download_url = first_asset["browser_download_url"]

    if pathlib.Path(jar_name).exists():
        print(f"{jar_name} already exists.")
        return 0

    print(f"Downloading {jar_download_url}")
    CHUNK_SIZE = 1024 * 1024  # 1MB
    with urllib.request.urlopen(jar_download_url) as jar_response, open(
        jar_name, mode="wb"
    ) as jarfile:
        while True:
            chunk: bytes = jar_response.read(CHUNK_SIZE)
            jarfile.write(chunk)
            print(".", end="", flush=True)
            if len(chunk) < CHUNK_SIZE:
                break

    print("\nDownload complete!")
    return 0


if __name__ == "__main__":
    sys.exit(main())
 

NISEMONO

New member
I wrote a tiny script to do this from the unix command line as well -

https://github.com/mattleblanc/current-KoLMafia

Enjoy!
I updated this script for MacOS and GitHub!
 
Top