40 lines
1.1 KiB
Bash
Executable file
40 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Open URLs to buy Tickets for the colosseo in one week
|
|
# Usage: ./tickets.sh [TIME]
|
|
# Opens the URLs to buy tickets in one week.
|
|
#
|
|
# Optional TIME controls the time to look for.
|
|
# Examples: ./tickets.sh "8:15 next week"
|
|
|
|
url_base="https://ticketing.colosseo.it/en/eventi/una-notte-al-colosseo/"
|
|
|
|
get_next_quarter_hour() {
|
|
# Get the current Unix timestamp
|
|
local current_timestamp=$(date +%s --date "${1:-next week}")
|
|
|
|
# Round up to the nearest quarter hour
|
|
local rounded_up_timestamp=$((current_timestamp + 900 - ((current_timestamp-1) % 900)))
|
|
|
|
date +"%Y-%m-%dT%I%%3A%M%%3A00Z" --date="@$rounded_up_timestamp"
|
|
}
|
|
|
|
construct_url() {
|
|
echo "${url_base}?t=$1#slotpicker"
|
|
}
|
|
|
|
open_in_firefox_incognito() {
|
|
firefox --private-window "$1"
|
|
}
|
|
|
|
datetime="$(get_next_quarter_hour "$1")"
|
|
url="$(construct_url "$datetime")"
|
|
|
|
if command -v firefox >/dev/null 2>&1; then
|
|
firefox "$url"
|
|
firefox --private-window "$url"
|
|
fi
|
|
|
|
if command -v chromium >/dev/null 2>&1; then
|
|
chromium "$url" >/dev/null 2>&1 &
|
|
chromium --incognito "$url" >/dev/null 2>&1 &
|
|
fi
|