Skip to content

Instantly share code, notes, and snippets.

@GavinPacini
Last active January 8, 2022 23:32
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GavinPacini/c198b071a89abf7ff41a3d2d2d75e51c to your computer and use it in GitHub Desktop.
Save GavinPacini/c198b071a89abf7ff41a3d2d2d75e51c to your computer and use it in GitHub Desktop.
HSE COVID Test Notifier for macOS
#!/bin/bash
# Intended for use on macOS with brew. Requires changes for other environments.
# run `brew install terminal-notifier jq` before use
# This script will run 12 times in a minute. Ideally, use it in a cronjob as so:
# * * * * * /path/to/covid.sh
# Change the path to wherever the script is
set -Eeuo pipefail
export PATH="/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin"
# Dublin facilities only below.
# Please see this comment for details on how to get these values for other facilities https://www.reddit.com/r/DevelEire/comments/rpne3r/if_any_other_irish_developers_are_struggling_to/hqaod2g/
facilities=( '$2y$10$s3AxFl4vwSwwJ0tPQe01dupr6NYp1bi2e9wG.unSUhDlPC6qRmoEa' '$2y$10$.EO9MxEzftNgKsjMCRmilOHcpvp.HZA9O0S/m4gB27HVsIO3umygi' '$2y$10$YwDZ7owcI/RPJTiNyjPvmOR3nzy.57NxGPJBzemTabHDhfLus.2s2' '$2y$10$X0LYnWbLnhgDgIXzJk9PvOsoX8vllMM/VAoOIvG6vqpPJ2F2bRo4W' '$2y$10$GevQM757ZpxFdlRqKBv/B.bRJ26LVoUCEYthhJpDojNLvsJj22Wq1' '$2y$10$GevQM757ZpxFdlRqKBv/B.bRJ26LVoUCEYthhJpDojNLvsYtdd45s' '$2y$10$750y8MOZDh.7I8oH9WtAFeHsExLIU.vj0lYdSxz8gxzZ8qIB5UZty' '$2y$10$RTROlaWx0UnFZft65UH2b.URVUCxcD2FVqod9p3KQiubh8v/jNCoi' '$2y$10$bFY4uwRvGodTow3YOozD1eoJQGzHSFNqubDQCHBWq3qFHedN2phW6' )
ids=( '13310' '14084' '14924' '15214' '16722' '16723' '16827' '14545' '17124' )
check () {
foundTests=0;
for i in "${!facilities[@]}"; do
echo "Iteration ${i}";
facility=$(printf "${facilities[i]}");
id=$(printf "${ids[i]}");
output=$(curl 'https://covid19test.healthservice.ie/swiftflow.php?future_days=1&minutes_buffer=60&enforce_future_days=1&enforce_today_or_tomorrow_only=0' \
-H 'accept: application/json, text/plain, */*' \
-H 'content-type: application/json' \
--data-raw "{\"task\":\"getConsultantAvailability\",\"facility_id\":\"${facility}\",\"type_id\":${id},\"flow\":\"routine\"}" \
--compressed -s \
| jq .data.type.total_slots_available);
if (( $output > 0 )); then
((foundTests=foundTests+1));
# Ideally track the place which has one now...
fi
done
if [ $foundTests -gt 0 ]; then
terminal-notifier -message 'Found a COVID test in your list!'
# Ideally actually book the feckin thing
fi
}
for j in {1..12}; do check && sleep 4; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment