Skip to content

Commit

Permalink
Update bcparks utility
Browse files Browse the repository at this point in the history
  • Loading branch information
villasv committed Aug 29, 2024
1 parent 5d9b37d commit a939f22
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions scripts/bcparks.py → projects/outdoors/bcparks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,37 @@
import os
import requests
import time
from datetime import datetime, timezone, timedelta

from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

logging.basicConfig(level=logging.INFO)

# TODO: receive form data as input
"""
Example
-------
Rafael
Rodrigues Ghossi
[email protected]
Natália
Turrioni Tavares
[email protected]
"""
default_headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-CA,en-US;q=0.9,en;q=0.8",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15",
"X-App-Version": "3ebc5f89d9acbddc41f8e8bca8bea1ded750d32e",
}


class BCParksReservation:
def watch(self, date):
while not self.check(date):
time.sleep(2)
os.system('say "Passes are available!"')
self.reserve(date)
while True:
while not self.check(date):
time.sleep(10)
os.system('say "Passes are available!"')
# self.reserve(date)

def check(self, date):
date = dateparser.parse(date).strftime("%Y-%m-%d")
base_url = "jd7n1axqh0.execute-api.ca-central-1.amazonaws.com/api"
park_params = "reservation?facility=Joffre%20Lakes&park=0363"
response = requests.get(f"https://{base_url}/{park_params}")
response = requests.get(
f"https://{base_url}/{park_params}", headers=default_headers
)
response = json.loads(response.text)
logging.debug(response)
print(response)

capacity = response[date]["DAY"]["capacity"]
if capacity == "Full":
Expand Down

0 comments on commit a939f22

Please sign in to comment.