Merge pull request 'Tolerance window' (#4) from develop into main
Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
from crossfit_booker import CrossFitBooker
|
from crossfit_booker import CrossFitBooker
|
||||||
@@ -14,15 +15,20 @@ if __name__ == "__main__":
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Reduce the verbosity of the requests library's logging
|
||||||
logging.getLogger("requests").setLevel(logging.WARNING)
|
logging.getLogger("requests").setLevel(logging.WARNING)
|
||||||
logging.info("Logging enhanced with request library noise reduction")
|
logging.info("Logging enhanced with request library noise reduction")
|
||||||
|
|
||||||
# Start the main runner
|
# Create an instance of the CrossFitBooker class
|
||||||
booker = CrossFitBooker()
|
booker = CrossFitBooker()
|
||||||
|
|
||||||
|
# Attempt to log in to the CrossFit booking system
|
||||||
|
# TODO: Make a authentication during running request to not get kicked out
|
||||||
if not booker.login():
|
if not booker.login():
|
||||||
|
# If login fails, log the error and exit the script
|
||||||
logging.error("Failed to login - Traceback: %s", traceback.format_exc())
|
logging.error("Failed to login - Traceback: %s", traceback.format_exc())
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Start continuous booking loop
|
# Start the continuous booking loop
|
||||||
booker.run()
|
booker.run()
|
||||||
logging.info("Script completed")
|
logging.info("Script completed")
|
||||||
@@ -42,9 +42,19 @@ APP_VERSION = "5.09.21"
|
|||||||
|
|
||||||
|
|
||||||
class CrossFitBooker:
|
class CrossFitBooker:
|
||||||
|
"""
|
||||||
|
A class for automating the booking of CrossFit sessions.
|
||||||
|
|
||||||
|
This class handles authentication, session availability checking,
|
||||||
|
booking, and notifications for CrossFit sessions.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize the CrossFitBooker with necessary attributes.
|
Initialize the CrossFitBooker with necessary attributes.
|
||||||
|
|
||||||
|
Sets up authentication tokens, session headers, mandatory parameters,
|
||||||
|
and initializes the SessionNotifier for sending notifications.
|
||||||
"""
|
"""
|
||||||
self.auth_token: Optional[str] = None
|
self.auth_token: Optional[str] = None
|
||||||
self.user_id: Optional[str] = None
|
self.user_id: Optional[str] = None
|
||||||
@@ -503,39 +513,46 @@ class CrossFitBooker:
|
|||||||
logging.error(f"Failed to book {session_type} session at {session_time} - Session: {session}")
|
logging.error(f"Failed to book {session_type} session at {session_time} - Session: {session}")
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
"""
|
"""
|
||||||
Main execution loop.
|
Main execution loop.
|
||||||
"""
|
"""
|
||||||
# Set up timezone
|
# Set up timezone
|
||||||
tz: pytz.timezone = pytz.timezone(TIMEZONE)
|
tz: pytz.timezone = pytz.timezone(TIMEZONE)
|
||||||
|
|
||||||
# Initial login
|
# Initial login
|
||||||
if not self.login():
|
if not self.login():
|
||||||
logging.error("Authentication failed - exiting program")
|
logging.error("Authentication failed - exiting program")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
current_time: datetime = datetime.now(tz)
|
current_time: datetime = datetime.now(tz)
|
||||||
logging.info(f"Current time: {current_time}")
|
logging.info(f"Current time: {current_time}")
|
||||||
|
|
||||||
# Always run booking cycle to check for preferred sessions and notify
|
# Always run booking cycle to check for preferred sessions and notify
|
||||||
self.run_booking_cycle(current_time)
|
self.run_booking_cycle(current_time)
|
||||||
|
|
||||||
|
# Run booking cycle at the target time for actual booking
|
||||||
|
target_time_str = current_time.strftime("%H:%M")
|
||||||
|
target_time = datetime.strptime(target_time_str, "%H:%M").replace(year=current_time.year, month=current_time.month, day=current_time.day, tzinfo=tz)
|
||||||
|
tolerance_window = timedelta(minutes=5)
|
||||||
|
|
||||||
|
# Check if current time is within the tolerance window after the target time
|
||||||
|
if (target_time <= current_time <= (target_time + tolerance_window)):
|
||||||
|
# Calculate the next booking window
|
||||||
|
next_booking_window = current_time + timedelta(minutes=20)
|
||||||
|
# Wait until the next booking window
|
||||||
|
time.sleep((next_booking_window - current_time).total_seconds())
|
||||||
|
else:
|
||||||
|
# Check again in 5 minutes
|
||||||
|
time.sleep(300)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Unexpected error in booking cycle: {str(e)} - Traceback: {traceback.format_exc()}")
|
||||||
|
time.sleep(60) # Wait before retrying after error
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
self.quit()
|
||||||
|
|
||||||
# Run booking cycle at the target time for actual booking
|
|
||||||
if current_time.strftime("%H:%M") == TARGET_RESERVATION_TIME:
|
|
||||||
# Wait until the next booking window
|
|
||||||
wait_until = current_time + timedelta(minutes=60)
|
|
||||||
time.sleep((wait_until - current_time).total_seconds())
|
|
||||||
else:
|
|
||||||
# Check again in 5 minutes
|
|
||||||
time.sleep(300)
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Unexpected error in booking cycle: {str(e)} - Traceback: {traceback.format_exc()}")
|
|
||||||
time.sleep(60) # Wait before retrying after error
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
self.quit()
|
|
||||||
|
|
||||||
def quit(self) -> None:
|
def quit(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
188
docs/crossfit_old.txt
Normal file
188
docs/crossfit_old.txt
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
https://sport.nubapp.com/web/index.php?id_application=81560887#/bookings
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/web/ajax/users/checkUser.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://sport.nubapp.com/web/index.php' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Origin: https://sport.nubapp.com' \
|
||||||
|
-H 'Sec-GPC: 1' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Cookie: applicationId=81560887; AWSALBTG=qZgepZq2iNqzI/cWNnAKBHv6qQNvEDQYbzdJs6cIbqhKfbfFM8GypnXrqH92HmKGpd7kbXgq8wyHjriS2RameqUTePW7wj70Ulvb0yrQC8hE2qq9sX/SDV0Jcv09jIUYiOmoe1P7YoqKve9EtJAJ0oIGXsvuR+ZTZfei2kkIssbE; AWSALBTGCORS=qZgepZq2iNqzI/cWNnAKBHv6qQNvEDQYbzdJs6cIbqhKfbfFM8GypnXrqH92HmKGpd7kbXgq8wyHjriS2RameqUTePW7wj70Ulvb0yrQC8hE2qq9sX/SDV0Jcv09jIUYiOmoe1P7YoqKve9EtJAJ0oIGXsvuR+ZTZfei2kkIssbE; PHPSESSID-FRONT=a8f7efe6df3a7bbaf6e2ab88f925df33' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: same-origin' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
--data-raw 'username=Kevin8407^&password=9vx03OSE'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/web/ajax/bookings/checkBookings.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://sport.nubapp.com/web/index.php' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Origin: https://sport.nubapp.com' \
|
||||||
|
-H 'Sec-GPC: 1' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Cookie: applicationId=81560887; AWSALBTG=qZgepZq2iNqzI/cWNnAKBHv6qQNvEDQYbzdJs6cIbqhKfbfFM8GypnXrqH92HmKGpd7kbXgq8wyHjriS2RameqUTePW7wj70Ulvb0yrQC8hE2qq9sX/SDV0Jcv09jIUYiOmoe1P7YoqKve9EtJAJ0oIGXsvuR+ZTZfei2kkIssbE; AWSALBTGCORS=qZgepZq2iNqzI/cWNnAKBHv6qQNvEDQYbzdJs6cIbqhKfbfFM8GypnXrqH92HmKGpd7kbXgq8wyHjriS2RameqUTePW7wj70Ulvb0yrQC8hE2qq9sX/SDV0Jcv09jIUYiOmoe1P7YoqKve9EtJAJ0oIGXsvuR+ZTZfei2kkIssbE; PHPSESSID-FRONT=a8f7efe6df3a7bbaf6e2ab88f925df33' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: same-origin' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
--data-raw 'items%5Bactivities%5D%5B0%5D%5Bid_activity_calendar%5D=18980977^&items%5Bactivities%5D%5B0%5D%5Bunit_price%5D=0^&items%5Bactivities%5D%5B0%5D%5Bn_guests%5D=0^&items%5Bactivities%5D%5B0%5D%5Bid_resource%5D=false^&discount_code=false'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/users/checkUser.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'app_version=5.09.21^&device_type=3^&username=Kevin8407^&password=1dd67168'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/login' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'device_type=3^&username=Kevin8407^&password=1dd67168'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/users/3191429/id_type_of_user' \
|
||||||
|
-X PUT \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTEyOTM0NTYsImV4cCI6MTc2NzEwODI1Niwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImlkX3VzZXIiOjMxOTE0MjksImlkX2FwcGxpY2F0aW9uIjo4MTU2MDg4NywicGFzc3dvcmRfaGFzaCI6ImMwZmFiNGVlNDFjMGFkZGU5ODU1OTAxZGIxNjQ0YmEwZjk2ZDZhMGEiLCJhdXRoZW50aWNhdGlvbl90eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJLZXZpbjg0MDcifQ.axAfZnzewEinSjnspgpO66tYJsbn1vAY6Dw-FivNjBZ4ylNWHQ1uWRbDAKYIhQMbQqcZ2_6HH_sa2YheIUA0fO2L276Qr9KZetGs_qwfn8AOkm63ALUQVKqwc-B6RGtmlE83m7gC5SgcPl6oNSoqV4k8lQ156V0Xr7E9fjcCNgjCJ8wFcHUp-XeVy54ixZHVxiLxFu1HHrlw0sisTwiQ7I3WAREn7XP7EwqFun9wwx8kyG1oggjShOecgiMX-68NIeJGwTcEBt2ssyKSRkibILw2p5BmABSmuYe_Hue4kYkyqvncBUJqMbpj8yeBKQUrT4undWPuYuWDftClClkM4A' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'app_version=5.09.21&id_type_of_user=1'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/users/changePassword.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: en-GB,en;q=0.8,fr-FR;q=0.5,fr;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTEyOTM0NTYsImV4cCI6MTc2NzEwODI1Niwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImlkX3VzZXIiOjMxOTE0MjksImlkX2FwcGxpY2F0aW9uIjo4MTU2MDg4NywicGFzc3dvcmRfaGFzaCI6ImMwZmFiNGVlNDFjMGFkZGU5ODU1OTAxZGIxNjQ0YmEwZjk2ZDZhMGEiLCJhdXRoZW50aWNhdGlvbl90eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJLZXZpbjg0MDcifQ.axAfZnzewEinSjnspgpO66tYJsbn1vAY6Dw-FivNjBZ4ylNWHQ1uWRbDAKYIhQMbQqcZ2_6HH_sa2YheIUA0fO2L276Qr9KZetGs_qwfn8AOkm63ALUQVKqwc-B6RGtmlE83m7gC5SgcPl6oNSoqV4k8lQ156V0Xr7E9fjcCNgjCJ8wFcHUp-XeVy54ixZHVxiLxFu1HHrlw0sisTwiQ7I3WAREn7XP7EwqFun9wwx8kyG1oggjShOecgiMX-68NIeJGwTcEBt2ssyKSRkibILw2p5BmABSmuYe_Hue4kYkyqvncBUJqMbpj8yeBKQUrT4undWPuYuWDftClClkM4A' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'app_version=5.09.21^&id_application=81560887^&id_user=3191429^&password=9vx03OSE^&old_password=1dd67168'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/users/getUsers.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: fr-FR,fr;q=0.8,en-GB;q=0.5,en;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTEyOTM0NTYsImV4cCI6MTc2NzEwODI1Niwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImlkX3VzZXIiOjMxOTE0MjksImlkX2FwcGxpY2F0aW9uIjo4MTU2MDg4NywicGFzc3dvcmRfaGFzaCI6ImMwZmFiNGVlNDFjMGFkZGU5ODU1OTAxZGIxNjQ0YmEwZjk2ZDZhMGEiLCJhdXRoZW50aWNhdGlvbl90eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJLZXZpbjg0MDcifQ.axAfZnzewEinSjnspgpO66tYJsbn1vAY6Dw-FivNjBZ4ylNWHQ1uWRbDAKYIhQMbQqcZ2_6HH_sa2YheIUA0fO2L276Qr9KZetGs_qwfn8AOkm63ALUQVKqwc-B6RGtmlE83m7gC5SgcPl6oNSoqV4k8lQ156V0Xr7E9fjcCNgjCJ8wFcHUp-XeVy54ixZHVxiLxFu1HHrlw0sisTwiQ7I3WAREn7XP7EwqFun9wwx8kyG1oggjShOecgiMX-68NIeJGwTcEBt2ssyKSRkibILw2p5BmABSmuYe_Hue4kYkyqvncBUJqMbpj8yeBKQUrT4undWPuYuWDftClClkM4A' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'app_version=5.09.21'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Rejoindre la liste d'attente
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/api/v4/activities/bookWaitingActivityCalendar.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: application/json, text/plain, */*' \
|
||||||
|
-H 'Accept-Language: en-GB,en;q=0.8,fr-FR;q=0.5,fr;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Referer: https://box.resawod.com/' \
|
||||||
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTEyOTQxMDYsImV4cCI6MTc2NzEwODkwNiwicm9sZXMiOlsiUk9MRV9VU0VSIl0sImlkX3VzZXIiOjMxOTE0MjksImlkX2FwcGxpY2F0aW9uIjo4MTU2MDg4NywicGFzc3dvcmRfaGFzaCI6ImMwZmFiNGVlNDFjMGFkZGU5ODU1OTAxZGIxNjQ0YmEwZjk2ZDZhMGEiLCJhdXRoZW50aWNhdGlvbl90eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJLZXZpbjg0MDcifQ.O5XhReqJkqOq1XLv-D_1nJE4hnPX7cyJXHEb_moJ2wV2JXVjbJ5yUf6Jvl0s4xVsN-oIcrvjK7ZmH82cWa2TevIpsaeqARjPpsxDbmWEQO5Cgo9ZHk_btEHJMsl0hMBEQ3uKDcALSxZQLPzDPFm9hdsObng3eKl96oCCZU-UqwkjDRPJPqAIIu3bNbf2okbB0KFMoYClWCvVMb9jV5MFY-OCfV8Eap140kIuZSTRmu9VfBSndcC5L5AN0tmDtSIwJRat3YWZQUbsDTkBSv1h1L72geJhw_yBGUUg7FJ06WJ2QbbuONmZmBcmTiololJCdOZ_3I-usDaL_TdoGnXapQ' \
|
||||||
|
-H 'Nubapp-Origin: user_apps' \
|
||||||
|
-H 'Origin: https://box.resawod.com' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Sec-Fetch-Dest: empty' \
|
||||||
|
-H 'Sec-Fetch-Mode: cors' \
|
||||||
|
-H 'Sec-Fetch-Site: cross-site' \
|
||||||
|
-H 'Priority: u=0' \
|
||||||
|
-H 'TE: trailers' \
|
||||||
|
--data-raw 'app_version=5.09.21&id_application=81560887&id_activity_calendar=19113851&id_user=3191429&action_by=3191429'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl 'https://sport.nubapp.com/web/ajax/users/checkUser.php' \
|
||||||
|
-X POST \
|
||||||
|
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0' \
|
||||||
|
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
|
||||||
|
-H 'Accept-Language: en-GB,en;q=0.8,fr-FR;q=0.5,fr;q=0.3' \
|
||||||
|
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
|
||||||
|
-H 'Connection: keep-alive' \
|
||||||
|
-H 'Cookie: applicationId=81560887; AWSALBTG=tdjfBXoHwnzTmQh0eDNuYHrW68ZQDdXa582yNdxiDUr+GEh2R+4Lx42mY6vO2d+fpQ5hdkoyamXmR6wcwUOALAarNyBKGRID8eW3/63w9f7fF1qMJB4Yq6jp/yv02dkzCw9W8lsDFnJAQ4XJOsq8oGyGVTGdS1Z5psXTHrO1qrfV; AWSALBTGCORS=tdjfBXoHwnzTmQh0eDNuYHrW68ZQDdXa582yNdxiDUr+GEh2R+4Lx42mY6vO2d+fpQ5hdkoyamXmR6wcwUOALAarNyBKGRID8eW3/63w9f7fF1qMJB4Yq6jp/yv02dkzCw9W8lsDFnJAQ4XJOsq8oGyGVTGdS1Z5psXTHrO1qrfV; PHPSESSID-FRONT=66ef232a6bd57e8f75128347e2b1e144' \
|
||||||
|
-H 'Upgrade-Insecure-Requests: 1' \
|
||||||
|
-H 'Sec-Fetch-Dest: document' \
|
||||||
|
-H 'Sec-Fetch-Mode: navigate' \
|
||||||
|
-H 'Sec-Fetch-Site: none' \
|
||||||
|
-H 'Sec-Fetch-User: ?1' \
|
||||||
|
-H 'Priority: u=0, i' \
|
||||||
|
--data-raw 'username=Kevin8407&password=9vx03OSE'
|
||||||
|
|
||||||
@@ -8,10 +8,13 @@ class SessionConfig:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_preferred_sessions():
|
def load_preferred_sessions(config_file="preferred_sessions.json"):
|
||||||
"""
|
"""
|
||||||
Load preferred sessions from a JSON file.
|
Load preferred sessions from a JSON file.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config_file (str): Path to the JSON file containing preferred sessions.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List[Tuple[int, str, str]]: List of preferred sessions in the format
|
List[Tuple[int, str, str]]: List of preferred sessions in the format
|
||||||
(day_of_week, start_time, session_name_contains)
|
(day_of_week, start_time, session_name_contains)
|
||||||
@@ -19,21 +22,34 @@ class SessionConfig:
|
|||||||
preferred_sessions = []
|
preferred_sessions = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("preferred_sessions.json", "r") as f:
|
# Attempt to open and read the JSON file
|
||||||
|
with open(config_file, "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
|
# Validate and parse each item in the JSON data
|
||||||
for item in data:
|
for item in data:
|
||||||
day_of_week = item.get("day_of_week", 0)
|
day_of_week = item.get("day_of_week", 0) # Default to Monday if not specified
|
||||||
start_time = item.get("start_time", "00:00")
|
start_time = item.get("start_time", "00:00") # Default to midnight if not specified
|
||||||
session_name_contains = item.get("session_name_contains", "")
|
session_name_contains = item.get("session_name_contains", "") # Default to empty string if not specified
|
||||||
|
|
||||||
|
# Append the parsed session to the list
|
||||||
preferred_sessions.append((day_of_week, start_time, session_name_contains))
|
preferred_sessions.append((day_of_week, start_time, session_name_contains))
|
||||||
except (FileNotFoundError, json.JSONDecodeError) as e:
|
|
||||||
logging.warning(f"Failed to load preferred sessions from file: {str(e)}")
|
except FileNotFoundError:
|
||||||
# Fall back to default hardcoded sessions
|
# Log a warning if the file is not found
|
||||||
# preferred_sessions = [
|
logging.warning(f"Configuration file '{config_file}' not found. Falling back to default settings.")
|
||||||
# (2, "18:30", "CONDITIONING"), # Wednesday 18:30 CONDITIONING
|
|
||||||
# (4, "17:00", "WEIGHTLIFTING"), # Friday 17:00 WEIGHTLIFTING
|
except json.JSONDecodeError:
|
||||||
# (5, "12:30", "HYROX"), # Saturday 12:30 HYROX
|
# Log a warning if the file is not a valid JSON
|
||||||
# ]
|
logging.warning(f"Failed to decode JSON from file '{config_file}'. Falling back to default settings.")
|
||||||
|
|
||||||
|
# Fallback to default hardcoded sessions if no valid sessions were loaded
|
||||||
|
if not preferred_sessions:
|
||||||
|
preferred_sessions = [
|
||||||
|
(2, "18:30", "CONDITIONING"), # Wednesday 18:30 CONDITIONING
|
||||||
|
(4, "17:00", "WEIGHTLIFTING"), # Friday 17:00 WEIGHTLIFTING
|
||||||
|
(5, "12:30", "HYROX"), # Saturday 12:30 HYROX
|
||||||
|
]
|
||||||
|
|
||||||
return preferred_sessions
|
return preferred_sessions
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
from session_notifier import SessionNotifier
|
from session_notifier import SessionNotifier
|
||||||
|
|||||||
Reference in New Issue
Block a user