Skip to content

Instantly share code, notes, and snippets.

@Frisch12
Created December 3, 2018 14:51
Show Gist options
  • Select an option

  • Save Frisch12/a52201c4eb989b5bc570ebf93ddb7c51 to your computer and use it in GitHub Desktop.

Select an option

Save Frisch12/a52201c4eb989b5bc570ebf93ddb7c51 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z ${2+x} ]; then
day=$(date +%d)
day=$(echo $day | sed 's/^0*//')
else
day=$2
if [ "$day" = "all" ]; then
today=$(date +%d)
for i in $(seq $today); do
$0 $1 $i
done
exit
fi
fi
winner=$(curl -s http://www.tboecker-it.de/rotary/days/$day/ | pup ".info p:not(.mittags) json{}" | jq "[.[] | {text: .text, winner: .children[].children[]?.text | split(\",\") | .[] | [ltrimstr(\" \") | rtrimstr(\" \")]} | if .winner[] == \"$1\" then .text else \"\" end] | join(\"\")" -r)
if [[ $winner == *"-"* ]]; then
echo "Gewonnen am $day.12. Preis: $winner"
else
echo "Nicht gewonnen am $day.12."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment