From c302c28c00074c3e23f51a55fe859ead758fd2ee Mon Sep 17 00:00:00 2001 From: Mihit Date: Sun, 9 Mar 2025 08:17:42 +1100 Subject: [PATCH] added file version and sha256 hashing --- omada-downloader.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/omada-downloader.py b/omada-downloader.py index 0b5bbe1..eaadba4 100644 --- a/omada-downloader.py +++ b/omada-downloader.py @@ -1,5 +1,6 @@ from bs4 import BeautifulSoup import requests +import hashlib def get_latest(): web_data = requests.get("https://support.omadanetworks.com/us/product/omada-software-controller/?resourceType=download") @@ -10,9 +11,20 @@ def get_latest(): urls.sort(reverse=True) return urls[0] +def get_sha256_hash(filename): + sha256 = hashlib.sha256() + with open(filename, "rb") as file: + while chunk := file.read(8192): # Read file in chunks + sha256.update(chunk) + return sha256.hexdigest() + def main(): + latest_url = get_latest() + remote_package_version = latest_url.split("/")[-1].split("_")[3] + print(f"Downloading version: {remote_package_version}") with open("omada_latest.deb", "wb") as file: - file.write(requests.get(get_latest()).content) + file.write(requests.get(latest_url).content) + print(f"File SHA256: {get_sha256_hash("omada_latest.deb")}") if __name__ == '__main__': main() \ No newline at end of file