You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
response.raise_for_status() # Raise an error if the request fails
194
197
total_size=int(response.headers.get("Content-Length", 0)) # Get file size
195
198
block_size=1024# Define block size for downloading (1 KB)
@@ -300,13 +303,22 @@ def check_updates(url: str) -> str: # Function to check for mod updates by compa
300
303
globalgLast_updated# Global variable to store the 'Last-Modified' header of the latest update
301
304
globalgUpdateMod_button# Global variable to reference the update button in the UI
302
305
debug("check_updates", "checking for updates") # Log the start of the update check
303
-
304
306
try: # Send a HEAD request to the URL to get metadata, but not the content
305
-
response=requests.head(url, allow_redirects=True)
306
-
response.raise_for_status() # Raise an exception if the request fails (non-2xx status code)
307
-
gLast_updated=response.headers.get("ETag", "No Last-Modified header found") # Get the 'Last-Modified' header from the response or provide a default message if it's not found
308
-
update_date=response.headers.get("Last-Modified", "No Last-Modified header found")
309
-
debug("check_updates Last updated date", gLast_updated) # Log the 'Last-Modified' header
debug("check_updates Last updated date", gLast_updated) # Log the 'Last-Modified' header
319
+
else:
320
+
add_log("Update response not OK")
321
+
310
322
ifgConfigUserInfo["lastupdate"] !=gLast_updated: # Compare the stored 'Last-Modified' date with the value received in the response
311
323
debug("check_updates", f"{gConfigUserInfo['lastupdate']} != {gLast_updated}") # Log the mismatch between the stored and received date
312
324
gUpdate_label.configure(text=f"Improvement Mod New Update - {truncate_string(update_date, max_length=550, placeholder="...")}") # Update the UI to indicate that a new update is available
@@ -321,7 +333,7 @@ def check_updates(url: str) -> str: # Function to check for mod updates by compa
321
333
add_log("Cannot check for updates") # Add the error message to the log
deffind_download_mirror() ->None:# Find the download link from moddb
656
+
deffind_download_mirror() ->None:
645
657
globalgModDownloadUrl
646
-
start_url="https://www.moddb.com/downloads/start/286602?referer=https%3A%2F%2Fwww.moddb.com%2Fmods%2Fimprovement-mod%2Fdownloads"# Find the download page from moddb
647
-
headers= { # Headers to mimic a real browser to get the mirror link
648
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
0 commit comments