diff options
author | Erich Eckner <git@eckner.net> | 2022-11-30 21:46:47 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-11-30 21:46:47 +0100 |
commit | 7e024cb110fedb07978ae4b3e0723b9cbe9b8c07 (patch) | |
tree | eb52789eb9cb494170891987f2d4408c9cf7e0d2 /import-kirchenmusik | |
parent | ef5f832ef5b9f171a8893ba684e93d7e1a49a61d (diff) | |
download | khal-extras-7e024cb110fedb07978ae4b3e0723b9cbe9b8c07.tar.xz |
import-kirchenmusik: also import Stimmbildung, too
Diffstat (limited to 'import-kirchenmusik')
-rwxr-xr-x | import-kirchenmusik | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/import-kirchenmusik b/import-kirchenmusik index 95589b3..0645665 100755 --- a/import-kirchenmusik +++ b/import-kirchenmusik @@ -1,5 +1,8 @@ #!/bin/bash +tmp_file=$(mktemp) +trap 'rm -f "${tmp_file}"' EXIT + printf '%s %s %s\n' \ 'oratorienchor' 'Erich' '' \ 'thueringer-saengerknaben' 'Familie' 'K: ' \ @@ -10,8 +13,77 @@ printf '%s %s %s\n' \ | 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 <<EOF +BEGIN:VCALENDAR +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:PUBLISH +$(cat "${tmp_file}") +EOF + + curl -Ss 'https://kirchenmusik-saalfeld.de/termine-dienste/stimmbildung/' \ + | sed -n ' + /^<p><strong>/ { + s@^\(<p><strong>[^<>]\+</strong>\)\(<br>[^<>]\+\)\(<br>\)@\1\2\n\1\3@ + P + D + p + } + ' \ + | grep Kasimir \ + | sed -n ' + s@^<p><strong>\S\+, @@ + T + s@</strong><br>@ @ + T + s@ \– @ @ + 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 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 <<EOF +BEGIN:VEVENT +DTSTART;TZID=Europe/Berlin:${jahr}${monat}${tag}T${von}00 +DTEND;TZID=Europe/Berlin:${jahr}${monat}${tag}T${bis}00 +DTSTAMP:$(date '+%+4Y%m%dT%H%M%S') +CREATED:$(date '+%+4Y%m%dT%H%M%S') +LAST-MODIFIED:$(date '+%+4Y%m%dT%H%M%S') +UID:$(echo "${jahr} ${monat} ${tag} ${von} ${bis}" | sha256sum | awk '{print $1}') +SUMMARY:K: Stimmbildung +LOCATION:Kantorat\, Kirchplatz 2\, Saalfeld\, 07318\, Deutschland +END:VEVENT +EOF + + done + + cat <<EOF +END:VCALENDAR +EOF + +} \ +| khal import -a "Familie" --batch |