blob: 23821ce5a309296c398bd64a19a7a193b4b888c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/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 <<EOF
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
EOF
cat "${tmp_file}"
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
}
' \
| sed -n '
s@^<p><strong>\S\+, @@
T
s/^.* \(Kasimir\|Friedrich\)/\1 \0/
T
s@</strong><br>@ @
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')-1))
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 "${wer} ${jahr} ${monat} ${tag} ${von} ${bis}" | sha256sum | awk '{print $1}')
SUMMARY:${wer:0:1}: Stimmbildung
LOCATION:Kantorat\, Kirchplatz 2\, Saalfeld\, 07318\, Deutschland
END:VEVENT
EOF
done
cat <<EOF
END:VCALENDAR
EOF
} \
| khal import -a "Familie" --batch
|