""" Bopihive Copyright (C) 2024 fzorb This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import requests import json import os import time import www request = requests.get("https://www.bopimo.com/api/releases/client/latest") if request.status_code != 200: exit("A network issue has happened and as such this program cannot continue.") response = request.text release = json.loads(response) linuxBuildExists = os.path.exists(f'./archive/{release["version"]}/linux.zip') windowsBuildExists = os.path.exists(f'./archive/{release["version"]}/windows.zip') at = time.time() if not linuxBuildExists or not windowsBuildExists: if not linuxBuildExists and not windowsBuildExists: print("Version hasn't been archived. Archiving both builds.") elif linuxBuildExists and not windowsBuildExists: print("Only the Linux build exists. Archiving Windows build.") elif windowsBuildExists and not linuxBuildExists: print("Only the Windows build exists. Archiving Linux build.") try: os.mkdir(f'./archive/{release["version"]}') except FileExistsError: print(f"Folder for version {release['version']} already exists.") if not windowsBuildExists: print("Downloading Windows build...") winRequest = requests.get(release['files']['windows']) with open(f'./archive/{release["version"]}/windows.zip', 'xb') as winFile: winFile.write(winRequest.content) if not linuxBuildExists: print("Downloading Linux build") linRequest = requests.get(release['files']['linux']) with open(f'./archive/{release["version"]}/linux.zip', 'xb') as winFile: winFile.write(linRequest.content) print(f"Succesfully archived in {time.time() - at}") www.renderIndex(at, release["version"]) else: print("Newest version already archived. Skipping!")