fix
This commit is contained in:
parent
d33ced1214
commit
46803f541e
11 changed files with 18 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ Artists.html
|
||||||
artists.xlsx
|
artists.xlsx
|
||||||
Trackerhub.zip
|
Trackerhub.zip
|
||||||
.env
|
.env
|
||||||
|
/__pycache__
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,7 +1,9 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ZIP_URL = "https://docs.google.com/spreadsheets/d/1S6WwM05O277npQbaiNk-jZlXK3TdooSyWtqaWUvAI78/export?format=zip"
|
SHEET_URL = "https://docs.google.com/spreadsheets/d/1S6WwM05O277npQbaiNk-jZlXK3TdooSyWtqaWUvAI78"
|
||||||
XLSX_URL = "https://docs.google.com/spreadsheets/d/1S6WwM05O277npQbaiNk-jZlXK3TdooSyWtqaWUvAI78/export?format=xlsx"
|
ZIP_URL = SHEET_URL + "/export?format=zip"
|
||||||
|
XLSX_URL = SHEET_URL + "/export?format=xlsx"
|
||||||
|
|
||||||
|
|
||||||
ZIP_FILENAME = "Trackerhub.zip"
|
ZIP_FILENAME = "Trackerhub.zip"
|
||||||
HTML_FILENAME = "Artists.html"
|
HTML_FILENAME = "Artists.html"
|
||||||
|
|
@ -20,11 +22,10 @@ exclude_names = {
|
||||||
|
|
||||||
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0 Safari/537.36"
|
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0 Safari/537.36"
|
||||||
|
|
||||||
BASE_URL = "https://artistgrid.cx/"
|
BASE_URL = "https://artistgrid.cx"
|
||||||
|
|
||||||
ARCHIVE_URLS = [
|
ARCHIVE_URLS = [
|
||||||
f"{BASE_URL}/",
|
f"{BASE_URL}/",
|
||||||
f"{BASE_URL}/index.html/",
|
|
||||||
f"{BASE_URL}/artists.html",
|
f"{BASE_URL}/artists.html",
|
||||||
f"{BASE_URL}/artists.csv",
|
f"{BASE_URL}/artists.csv",
|
||||||
f"{BASE_URL}/artists.xlsx",
|
f"{BASE_URL}/artists.xlsx",
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ from archive import archive_all_urls
|
||||||
from notify import send_discord_message
|
from notify import send_discord_message
|
||||||
from utils import hash_file
|
from utils import hash_file
|
||||||
|
|
||||||
last_csv_hash = None
|
last_html_hash = None
|
||||||
last_csv_data = {}
|
last_csv_data = {}
|
||||||
|
|
||||||
def update_loop():
|
def update_loop():
|
||||||
global last_csv_hash, last_csv_data
|
global last_html_hash, last_csv_data
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
@ -19,29 +19,30 @@ def update_loop():
|
||||||
download_xlsx()
|
download_xlsx()
|
||||||
generate_csv()
|
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")
|
current_data = read_csv_to_dict("artists.csv")
|
||||||
|
|
||||||
if last_csv_hash is None:
|
if last_html_hash is None:
|
||||||
print("ℹ️ Initial CSV hash stored.")
|
print("ℹ️ Initial HTML hash stored.")
|
||||||
elif current_hash != last_csv_hash:
|
elif current_hash != last_html_hash:
|
||||||
print("🔔 CSV has changed! Archiving URLs...")
|
print("🔔 Artists.html has changed! Archiving URLs...")
|
||||||
|
|
||||||
changes = detect_changes(last_csv_data, current_data)
|
changes = detect_changes(last_csv_data, current_data)
|
||||||
if changes:
|
if changes:
|
||||||
message = "**CSV Update Detected:**\n" + "\n".join(changes)
|
message = "**CSV Update Detected:**\n" + "\n".join(changes)
|
||||||
send_discord_message(message)
|
send_discord_message(message)
|
||||||
else:
|
else:
|
||||||
print("ℹ️ No detectable content changes found.")
|
print("ℹ️ No detectable content changes found in CSV.")
|
||||||
|
|
||||||
archive_all_urls()
|
archive_all_urls()
|
||||||
else:
|
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
|
last_csv_data = current_data
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"⚠️ Error updating files: {e}")
|
print(f"⚠️ Error updating files: {e}")
|
||||||
|
|
||||||
time.sleep(600)
|
time.sleep(6)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue