#!/bin/bash tmp_file=$(mktemp) trap 'rm -f "${tmp_file}"' EXIT printf '%s %s %s\n' \ 'oratorienchor' 'Erich' '' \ 'thueringer-saengerknaben' 'Familie' 'K&F: ' \ | while read -r Chor Kalender Extra; do curl -Ss 'https://kirchenmusik-saalfeld.de/termine-dienste/'"${Chor}"'/' \ | grep '^\[{"@context":"http://schema.org"' \ | jq -cr '.[].url' \ | while read -r url; do curl -Ss "${url%/}/?ical=1" \ | sed ' /^BEGIN:VTIMEZONE\s*$/,/^END:VTIMEZONE\s*$/ w'"${tmp_file}"' s@^SUMMARY:@\0'"${Extra}"'@ ' \ | khal import -a "${Kalender}" --batch done done { cat </ { s@^\(

[^<>]\+\)\(
[^<>]\+\)\(
\)@\1\2\n\1\3@ P D p } ' \ | sed -n ' s@^

\S\+, @@ T s/^.* \(Kasimir\|Friedrich\)/\1 \0/ T s@
@ @ T s@ \– @ @g T s@ Uhr .*$@@ T p ' \ | sed "$( for m in {01..12}; do printf 's@\\b%s\\b@%s@\n' \ "$(date -d "2022-${m}-01" '+%B')" \ "${m}" done )"' s/://g ' \ | while read -r wer tag monat von bis; do tag="${tag%.}" jahr=$(date '+%Y') while [ $(($(date '+%s')-60*60*24*100)) -gt $(date -d "${jahr}-${monat}-${tag}" '+%s') ]; do jahr=$((jahr+1)) done cat <