Created
March 28, 2023 13:18
-
-
Save jwmcgettigan/84b4681af0ea5f0469cd20e7c1c0fb4c to your computer and use it in GitHub Desktop.
Python script that checks for global entry openings that are before a given date every 30 seconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script checks every 30 seconds for appointment openings at the provided locations before the given date. | |
# If an appointment opening is found, then a Windows notification will be created. | |
# The notification can be clicked to launch the TTP website for a quicker login. | |
from datetime import datetime | |
import requests | |
import time | |
from winotify import Notification | |
APPOINTMENTS_URL = "https://ttp.cbp.dhs.gov/schedulerapi/slots?orderBy=soonest&limit=1&locationId={}&minimum=1" | |
# You can find IDs here: https://ttp.cbp.dhs.gov/schedulerapi/locations/?temporary=false&inviteOnly=false&operational=true&serviceName=Global%20Entry | |
LOCATION_IDS = { | |
'*Tampa Airport': 8020, | |
#'Orlando Airport': 5380, | |
#'Sanford': 5447, | |
#'Orlando Convention Center': 16506, | |
#'Treasure Coast Airport': 16248 | |
} | |
BEFORE_DATE = datetime(2023, 4, 26, 11, 0) # year, month, day, hour, minute | |
def check_locations(): | |
for city, id in LOCATION_IDS.items(): | |
url = APPOINTMENTS_URL.format(id) | |
response = requests.get(url) | |
if response.status_code != 204: | |
appointments = response.json() | |
if appointments: | |
utc = datetime.strptime(appointments[0]['startTimestamp'], '%Y-%m-%dT%H:%M') | |
if utc < BEFORE_DATE: | |
message = "{}: Found an appointment at {}!".format(city, utc.strftime('%b %d %Y %I:%M%p')) | |
print(message) | |
toast = Notification( | |
app_id="Global Entry Notifier", | |
title="Global Entry Opening Detected", | |
msg=message, | |
duration="long", | |
launch="https://ttp.cbp.dhs.gov/dashboard" | |
) | |
toast.show() | |
else: | |
print("No appointments available at {}!".format(city)) | |
time.sleep(1) | |
while True: | |
print(f"------- {datetime.now().strftime('%b %d %Y %I:%M%p')} -------") | |
check_locations() | |
time.sleep(30) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment