This commit is contained in:
Eduard Prigoana 2025-07-22 07:31:56 +03:00
parent d33ced1214
commit 46803f541e
11 changed files with 18 additions and 15 deletions

View file

@ -7,11 +7,11 @@ from archive import archive_all_urls
from notify import send_discord_message
from utils import hash_file
last_csv_hash = None
last_html_hash = None
last_csv_data = {}
def update_loop():
global last_csv_hash, last_csv_data
global last_html_hash, last_csv_data
while True:
try:
@ -19,29 +19,30 @@ def update_loop():
download_xlsx()
generate_csv()
current_hash = hash_file("artists.csv")
# Hash the Artists.html instead of artists.csv
current_hash = hash_file("Artists.html")
current_data = read_csv_to_dict("artists.csv")
if last_csv_hash is None:
print(" Initial CSV hash stored.")
elif current_hash != last_csv_hash:
print("🔔 CSV has changed! Archiving URLs...")
if last_html_hash is None:
print(" Initial HTML hash stored.")
elif current_hash != last_html_hash:
print("🔔 Artists.html has changed! Archiving URLs...")
changes = detect_changes(last_csv_data, current_data)
if changes:
message = "**CSV Update Detected:**\n" + "\n".join(changes)
send_discord_message(message)
else:
print(" No detectable content changes found.")
print(" No detectable content changes found in CSV.")
archive_all_urls()
else:
print(" CSV unchanged. No archiving needed.")
print(" Artists.html unchanged. No archiving needed.")
last_csv_hash = current_hash
last_html_hash = current_hash
last_csv_data = current_data
except Exception as e:
print(f"⚠️ Error updating files: {e}")
time.sleep(600)
time.sleep(6)