added file version and sha256 hashing
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
from bs4 import BeautifulSoup
 | 
					from bs4 import BeautifulSoup
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
 | 
					import hashlib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_latest():
 | 
					def get_latest():
 | 
				
			||||||
    web_data = requests.get("https://support.omadanetworks.com/us/product/omada-software-controller/?resourceType=download")
 | 
					    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)
 | 
					    urls.sort(reverse=True)
 | 
				
			||||||
    return urls[0]
 | 
					    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():
 | 
					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:
 | 
					    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__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    main()
 | 
					    main()
 | 
				
			||||||
		Reference in New Issue
	
	Block a user