2022-06-03 17:32:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
gemeinde=13
|
|
|
|
sammelgebiet=1008
|
|
|
|
|
|
|
|
today="$(date +%Y-%m-%d)"
|
|
|
|
tomorrow="$(date --date='tomorrow' +%Y-%m-%d)"
|
|
|
|
this_year="$(date +%Y)"
|
|
|
|
next_year="$(date --date='next year' +%Y)"
|
|
|
|
|
|
|
|
function format_collections {
|
|
|
|
if [[ "$1" == *"Kehricht"* ]]; then
|
|
|
|
echo -n " "
|
|
|
|
fi
|
|
|
|
if [[ "$1" == *"Grüngut"* ]]; then
|
|
|
|
echo -n " "
|
|
|
|
fi
|
|
|
|
if [[ "$1" == *"Karton"* ]]; then
|
|
|
|
echo -n " "
|
|
|
|
fi
|
|
|
|
if [[ "$1" == *"Alteisen"* ]]; then
|
|
|
|
echo -n " "
|
|
|
|
fi
|
|
|
|
if [[ "$1" == *"Papier"* ]]; then
|
|
|
|
echo -n " "
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
data="$(curl -s "https://www.real.sammelkalender.ch/app/appSammeldaten.php?nGem=$gemeinde&nAbar=null&nSage=$sammelgebiet&jahr1=$this_year&jahr2=$next_year")"
|
|
|
|
collection_today="$(echo "$data" | jq -r ".[] | select(.DATUM == \"$today\") | .AbarOne")"
|
|
|
|
collection_tomorrow="$(echo "$data" | jq -r ".[] | select(.DATUM == \"$tomorrow\") | .AbarOne")"
|
|
|
|
|
2022-06-05 10:56:50 +00:00
|
|
|
has_printed=0
|
2022-06-03 17:32:24 +00:00
|
|
|
if [[ "$collection_today" != "null" ]]; then
|
|
|
|
format_collections $collection_today
|
2022-06-05 10:56:50 +00:00
|
|
|
has_printed=1
|
2022-06-03 17:32:24 +00:00
|
|
|
fi
|
|
|
|
if [[ "$collection_tomorrow" != "null" ]]; then
|
|
|
|
echo "tomorrow: $(format_collections $collection_tomorrow)"
|
2022-06-05 10:56:50 +00:00
|
|
|
has_printed=1
|
|
|
|
fi
|
|
|
|
# hide the module
|
|
|
|
if [[ "$has_printed" == "0" ]]; then
|
|
|
|
echo ""
|
2022-06-03 17:32:24 +00:00
|
|
|
fi
|