online status tuhlogger

This commit is contained in:
Danilo Reyes 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")
return
offline_div = details_row.find("div", class_="offline")
if not offline_div:
print("No offline class found, code changed")
return
online_div = details_row.find("div", class_="online")
if online_div:
last_seen_time = datetime.now()
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_time = parse_last_seen(last_seen_text)
if not last_seen_time:
print("No last seen time could be extracted")
return
last_seen_text = offline_div.text.strip()
last_seen_time = parse_last_seen(last_seen_text)
if not last_seen_time:
print("No last seen time could be extracted")
return
latest_log = fetch_latest_log()
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.")
return
latest_log = fetch_latest_log()
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.")
return
if latest_log and last_seen_time.hour == latest_log.hour:
print(f"An entry for this hour already exists. Skipping new log.")
return
if latest_log and last_seen_time.hour == latest_log.hour:
print(f"An entry for this hour already exists. Skipping new log.")
return
timestamp = last_seen_time.strftime("%Y-%m-%d %H:%M:%S")
log_activity(timestamp)