From fa84593dee90101e3571d106964c5f16f7cc6d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 1 Sep 2025 18:23:24 +0200 Subject: [PATCH] feat: init --- tickets.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tickets.sh diff --git a/tickets.sh b/tickets.sh new file mode 100755 index 0000000..435f8fa --- /dev/null +++ b/tickets.sh @@ -0,0 +1,40 @@ +#!/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