diff --git a/config/constants.py b/config/constants.py index 75bf241..5e04b18 100644 --- a/config/constants.py +++ b/config/constants.py @@ -11,6 +11,8 @@ SERVICE_ID = "601" # RESOURCE_ID =16402 # 222 study room # RESOURCE_ID =15883 #66 second best RESOURCE_ID = 15502 # 17 cool snipe with view +RESOURCE_IDS = [] +# RESOURCE_IDS = [15502, 15883] TIMEZONE = "Europe/Berlin" # SSO_PROVIDER = "kit" # Available: kit (add more in auth/providers/) diff --git a/main.py b/main.py index e21798b..ade62f9 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from auth.session import AnnySession from booking.client import BookingClient from utils.helpers import get_future_datetime import pytz -from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES +from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES, RESOURCE_IDS def main(): @@ -48,15 +48,25 @@ def main(): start = get_future_datetime(hour=time_["start"]) end = get_future_datetime(hour=time_["end"]) + # maybe add if reservation fails try next id and if everything fails do ^ + + for seat_id in RESOURCE_IDS: + resource_id = seat_id + reservation_success = booking.reserve(resource_id, start, end) + if reservation_success: + return True + if RESOURCE_ID: resource_id = RESOURCE_ID + reservation_success = booking.reserve(resource_id, start, end) + if reservation_success: + return True + resource_id = booking.find_available_resource(start, end) + reservation_success = booking.reserve(resource_id, start, end) + if reservation_success: + return True else: - resource_id = booking.find_available_resource(start, end) - - if resource_id: - booking.reserve(resource_id, start, end) - else: - print("⚠️ No available slots found.") + print("⚠️ No available slots found. ( or other error )") except Exception as e: print(f"❌ Error booking slot {time_['start']}-{time_['end']}: {e}")