From b2d6ac1a6aac3a1b61ec5c96b9cbe54ffb15394e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 13 Jan 2019 16:56:48 +0100 Subject: Initial commit --- heutigeBachkantaten | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100755 heutigeBachkantaten diff --git a/heutigeBachkantaten b/heutigeBachkantaten new file mode 100755 index 0000000..faabb7e --- /dev/null +++ b/heutigeBachkantaten @@ -0,0 +1,227 @@ +#!/bin/bash + +Y=$(date +%Y) +G=$((Y%19 + 1)) +C=$((Y/100 +1)) +X=$(((3*C)/4 - 12)) +Z=$(((8*C+5)/25 - 5)) +D=$(((5*Y)/4-X-10)) +E=$(((11*G+50+Z-(X%30))%30)) +if [ ${E} -eq 25 ] && [ ${G} -gt 11 ] || [ ${E} -eq 24 ]; then + E=$((E+1)) +fi +N=$((44-E)) +if [ ${N} -lt 21 ]; then + N=$((N+30)) +fi +N=$((N+7-((D+N)%7))) +Ostern=$(( + $(date +%s -d"${Y}-03-01") + (N-1)*24*60*60 +)) + +# $1. Sonntag nach $2 +sonntag_nach() { + echo $(( + $(date +%s -d@$2) + 24*60*60*(7*$1 + 1 - $(date +%u -d@$(($2+24*60*60)))) + )) +} + +curl -Ss 'https://de.wikipedia.org/wiki/Liste_der_Bachkantaten' \ + | sed -n ' + \#^

Liste der Kantaten#,\#^

# p + ' \ + | tr -d '\n' \ + | sed ' + s#]*>[^<>]*##g + s#[^<>]*##g + s#]*>##g + s###g + ' \ + | sed ' + s#<\(h2\|tr\|tbody\)#\n\0#g + s##\0\n#g + ' \ + | grep -vxF '' \ + | sed -n ' + \## d + \##,\## p + ' \ + | sed -n ' + 1 d + $ d + s#^.*]\+\)\?>\([^<>]\+\)[^<>]\+\([^<>]*\)\(.*\).*#\2 \3# + T err + s/^\(\S\+\) \([0-9]\+\)\( \|$\)/\1_\2\3/ + p + b + :err + s/.*/passt nicht: "\0"/ + w /dev/stderr + ' \ + | sed ' + /^\S\+ $/d + s/^\(\S\+ \).*(\([^()]\+\)).*$/\1real:\2/ + t + s/^\(\S\+ \)\(Sonntag nach \)/\11. \2/ + s/^\(\S\+ \)\([0-9]\+\)\. Sonntag nach \(\S\+\)$/\1\2+ \3/ + ' \ + | sed ' + / Dramma per musica$/d + / Huldigungskantate$/d + / Ratswechsel$/d + / Trauerfeier$/d + / Unbekannter Anlass$/d + / Weltliche Kantate$/d + ' \ + | while read -r bwv plus sonntag; do + if [ -z "${plus##*+}" ]; then + plus="${plus%+}" + else + if [ -z "${sonntag}" ]; then + sonntag="${plus}" + else + sonntag="${plus} ${sonntag}" + fi + plus='' + fi + if [ -z "${sonntag##real:*}" ]; then + sonntag="${sonntag#real:}" + tag="${sonntag%%. *}" + sonntag="${sonntag#*. }" + for monat in {01..13}; do + if [ ${monat} -eq 13 ]; then + >&2 printf 'unbekannter Monat "%s"\n' "${sonntag}" + exit 1 + fi + if [ "$(date +%B -d"${Y}-${monat}-01")" = "${sonntag}" ]; then + break + fi + done + ausgabe=$( + date +%s -d"${Y}-${monat}-${tag}" + ) + elif [ -z "${sonntag%%*. Adventsonntag}" ]; then + ausgabe=$( + sonntag_nach "$((${sonntag%. Adventsonntag}-4))" "$(date +%s -d"${Y}-12-24")" + ) + elif [ "${sonntag}" = 'Weihnachten' ]; then + ausgabe=$( + date +%s -d"${Y}-12-24" + ) + elif [ -z "${sonntag%?. Weihnachtstag}" ]; then + ausgabe=$(( + $(date +%s -d"${Y}-12-24") + ${sonntag%. Weihnachtstag}*24*60*60 + )) + elif [ "${sonntag}" = 'Neujahr' ]; then + ausgabe=$( + date +%s -d"${Y}-01-01" + ) + elif [ "${sonntag}" = 'Epiphanias' ]; then + ausgabe=$( + date +%s -d"${Y}-01-06" + ) + elif [ "${sonntag}" = 'Septuagesimae' ]; then + ausgabe=$(( + "${Ostern}" - 7*9*24*60*60 + )) + elif [ "${sonntag}" = 'Sexagesimae' ]; then + ausgabe=$(( + "${Ostern}" - 7*8*24*60*60 + )) + elif [ "${sonntag}" = 'Estomihi' ]; then + ausgabe=$(( + "${Ostern}" - 7*7*24*60*60 + )) + elif [ "${sonntag}" = 'Invocabit' ]; then + ausgabe=$(( + "${Ostern}" - 7*6*24*60*60 + )) + elif [ "${sonntag}" = 'Reminiscere' ]; then + ausgabe=$(( + "${Ostern}" - 7*5*24*60*60 + )) + elif [ "${sonntag}" = 'Oculi' ]; then + ausgabe=$(( + "${Ostern}" - 7*4*24*60*60 + )) + elif [ "${sonntag}" = 'Laetare' ]; then + ausgabe=$(( + "${Ostern}" - 7*3*24*60*60 + )) + elif [ "${sonntag}" = 'Judica' ]; then + ausgabe=$(( + "${Ostern}" - 7*2*24*60*60 + )) + elif [ "${sonntag}" = 'Palmsonntag' ]; then + ausgabe=$(( + "${Ostern}" - 7*24*60*60 + )) + elif [ -z "${sonntag%?. Osterfesttag}" ]; then + ausgabe=$(( + Ostern + (${sonntag%. Osterfesttag}-1)*24*60*60 + )) + elif [ "${sonntag}" = 'Quasimodogeniti' ]; then + ausgabe=$(( + "${Ostern}" + 7*24*60*60 + )) + elif [ "${sonntag}" = 'Misericordias Domini' ]; then + ausgabe=$(( + "${Ostern}" + 7*2*24*60*60 + )) + elif [ "${sonntag}" = 'Jubilate' ]; then + ausgabe=$(( + "${Ostern}" + 7*3*24*60*60 + )) + elif [ "${sonntag}" = 'Cantate' ]; then + ausgabe=$(( + "${Ostern}" + 7*4*24*60*60 + )) + elif [ "${sonntag}" = 'Rogate' ]; then + ausgabe=$(( + "${Ostern}" + 7*5*24*60*60 + )) + elif [ "${sonntag}" = 'Christi Himmelfahrt' ]; then + ausgabe=$(( + "${Ostern}" + (7*6-3)*24*60*60 + )) + elif [ "${sonntag}" = 'Exaudi' ]; then + ausgabe=$(( + "${Ostern}" + 7*6*24*60*60 + )) + elif [ -z "${sonntag%?. Pfingstfesttag}" ]; then + ausgabe=$(( + Ostern + (${sonntag%. Pfingstfesttag}-1 + 7*7)*24*60*60 + )) + elif [ "${sonntag}" = 'Trinitatis' ]; then + ausgabe=$(( + "${Ostern}" + 7*8*24*60*60 + )) + elif [ "${sonntag}" = 'Gratulationskantate' ] || \ + [ "${sonntag}" = 'Geburtstagskantate' ]; then + ausgabe=$( + date +%s -d"${Y}-07-25" + ) + elif [ "${sonntag}" = 'Hochzeit' ] || \ + [ "${sonntag}" = 'Trauung' ]; then + ausgabe=$( + date +%s -d"${Y}-09-15" + ) + else + >&2 printf '%s >>%s<<\n' "${bwv}" "${sonntag}" + continue + fi + if [ -n "${plus}" ]; then + ausgabe=$( + sonntag_nach "${plus}" "${ausgabe}" + ) + fi + printf '%s %s\n' \ + "${bwv}" \ + "$(date +%F -d@"${ausgabe}")" + done \ + | grep " $(date +%F)$" \ + | cut -d' ' -f1 \ + | tr '\n' ' ' \ + | sed ' + s/ $/\n/ + ' -- cgit v1.2.3