PrismLauncher / meta

Prism Launcher Metadata generation scripts
Microsoft Public License
16 stars 17 forks source link

chore: add LWJGL 3.3.2 ARM32/ARM64 Linux #25

Closed theofficialgman closed 11 months ago

theofficialgman commented 11 months ago

generated partially automatically using the help of a python script written by chatGPT. Basically I just removed everything but the lwjgl 3.3.1 from the library-patches.json, renamed it to input.json, find/replace all 3.3.1 with 3.3.2, then ran the script which updated the sha1 and sizes, finally pasted those contents back into library-patches.json

import json
import requests
import hashlib

# Function to download a file and return its SHA1 hash and size
def download_file(url):
    response = requests.get(url)
    if response.status_code == 200:
        content = response.content
        sha1 = hashlib.sha1(content).hexdigest()
        size = len(content)
        return sha1, size
    return None, None

# Load the JSON data from the input file
input_file = 'input.json'
with open(input_file, 'r') as f:
    data = json.load(f)

# Iterate through libraries
for library in data:
    additional_libraries = library['additionalLibraries']
    for additional_library in additional_libraries:
        downloads = additional_library['downloads']
        for download_type, download_info in downloads.items():
            url = download_info['url']
            sha1, size = download_file(url)
            if sha1 and size:
                download_info['sha1'] = sha1
                download_info['size'] = size

# Save the updated JSON data
output_file = 'output.json'
with open(output_file, 'w') as f:
    json.dump(data, f, indent=2)

print(f'Updated JSON data saved to {output_file}')