feat: Only books preferred activities

I changed the runner to only book preferred
sessions and ignore all others.
This commit is contained in:
kbe
2025-07-18 21:41:16 +02:00
parent 3a0af18b73
commit 870a65301d

View File

@@ -29,7 +29,8 @@ if not all([USERNAME, PASSWORD]):
APPLICATION_ID = "81560887" APPLICATION_ID = "81560887"
CATEGORY_ID = "677" # Activity category ID for CrossFit CATEGORY_ID = "677" # Activity category ID for CrossFit
TIMEZONE = "Europe/Paris" # Adjust to your timezone TIMEZONE = "Europe/Paris" # Adjust to your timezone
TARGET_RESERVATION_TIME = "20:01" # When bookings open (8 PM) # TARGET_RESERVATION_TIME = "20:01" # When bookings open (8 PM)
TARGET_RESERVATION_TIME = "21:40" # When bookings open (8 PM)
DEVICE_TYPE = "3" DEVICE_TYPE = "3"
# Retry configuration # Retry configuration
@@ -365,7 +366,7 @@ class CrossFitBooker:
activities = sessions_data.get("data", {}).get("activities_calendar", []) activities = sessions_data.get("data", {}).get("activities_calendar", [])
# Find sessions to book (both preferred and any available) # Find sessions to book (prefered only)
sessions_to_book = [] sessions_to_book = []
for session in activities: for session in activities:
if not self.is_session_bookable(session, current_time): if not self.is_session_bookable(session, current_time):
@@ -373,9 +374,6 @@ class CrossFitBooker:
if self.matches_preferred_session(session, current_time): if self.matches_preferred_session(session, current_time):
sessions_to_book.append(("Preferred", session)) sessions_to_book.append(("Preferred", session))
elif current_time.strftime("%H:%M") == TARGET_RESERVATION_TIME:
# At booking time, consider all available sessions
sessions_to_book.append(("Available", session))
if not sessions_to_book: if not sessions_to_book:
logging.info("No matching sessions found to book") logging.info("No matching sessions found to book")
@@ -384,7 +382,7 @@ class CrossFitBooker:
# Book sessions (preferred first) # Book sessions (preferred first)
sessions_to_book.sort(key=lambda x: 0 if x[0] == "Preferred" else 1) sessions_to_book.sort(key=lambda x: 0 if x[0] == "Preferred" else 1)
for session_type, session in sessions_to_book: for session_type, session in sessions_to_book:
session_time = datetime.strptime(session["start_datetime"], "%Y-%m-%d %H:%M:%S") session_time = datetime.strptime(session["start_timestamp"], "%Y-%m-%d %H:%M:%S")
logging.info(f"Attempting to book {session_type} session at {session_time} ({session['name_activity']})") logging.info(f"Attempting to book {session_type} session at {session_time} ({session['name_activity']})")
if self.book_session(session["id_activity_calendar"]): if self.book_session(session["id_activity_calendar"]):
logging.info(f"Successfully booked {session_type} session at {session_time}") logging.info(f"Successfully booked {session_type} session at {session_time}")