online status tuhlogger

This commit is contained in:
2025-03-27 11:04:05 -06:00
parent 469638b524
commit 1e452fb24e

View File

@@ -74,25 +74,29 @@ def scrape_and_log(url: str) -> None:
print("No details-row found, code changed") print("No details-row found, code changed")
return return
offline_div = details_row.find("div", class_="offline") online_div = details_row.find("div", class_="online")
if not offline_div: if online_div:
print("No offline class found, code changed") last_seen_time = datetime.now()
return if not online_div:
offline_div = details_row.find("div", class_="offline")
if not offline_div and not online_div:
print("No offline class found, code changed")
return
last_seen_text = offline_div.text.strip() last_seen_text = offline_div.text.strip()
last_seen_time = parse_last_seen(last_seen_text) last_seen_time = parse_last_seen(last_seen_text)
if not last_seen_time: if not last_seen_time:
print("No last seen time could be extracted") print("No last seen time could be extracted")
return return
latest_log = fetch_latest_log() latest_log = fetch_latest_log()
if latest_log and last_seen_time.date() <= latest_log.date(): if latest_log and last_seen_time.date() <= latest_log.date():
print(f"A log already exists for {latest_log} or later. Skipping new log.") print(f"A log already exists for {latest_log} or later. Skipping new log.")
return return
if latest_log and last_seen_time.hour == latest_log.hour: if latest_log and last_seen_time.hour == latest_log.hour:
print(f"An entry for this hour already exists. Skipping new log.") print(f"An entry for this hour already exists. Skipping new log.")
return return
timestamp = last_seen_time.strftime("%Y-%m-%d %H:%M:%S") timestamp = last_seen_time.strftime("%Y-%m-%d %H:%M:%S")
log_activity(timestamp) log_activity(timestamp)