46 lines
1.4 KiB
Bash
Executable File
46 lines
1.4 KiB
Bash
Executable File
#!/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")"
|
|
|
|
has_printed=0
|
|
if [[ "$collection_today" != "null" ]]; then
|
|
format_collections $collection_today
|
|
has_printed=1
|
|
fi
|
|
if [[ "$collection_tomorrow" != "null" ]]; then
|
|
echo "tomorrow: $(format_collections $collection_tomorrow)"
|
|
has_printed=1
|
|
fi
|
|
# hide the module
|
|
if [[ "$has_printed" == "0" ]]; then
|
|
echo ""
|
|
fi
|