aoc/get_input.sh

34 lines
612 B
Bash
Raw Normal View History

2024-08-13 08:32:35 -07:00
#!/usr/bin/env sh
2021-07-14 13:50:33 -07:00
2023-11-29 13:51:48 -08:00
get(){
curl -s --cookie "session=$1" "$2" | perl -pe 'chomp if eof' > "$3"
}
2024-12-02 06:22:25 -08:00
if [ -n "${2+x}" ] && [ -n "${3+x}" ]; then
year="20$2"
day="$3"
if [ "$day" -lt 10 ]; then
d="0$day"
else
d="$day"
fi
url="https://adventofcode.com/$year/day/$day/input"
get "$1" "$url" "input/$year/$d"
exit 0
fi
#rm -rf input
for year in {2015..2024}; do
2022-09-09 11:13:53 -07:00
mkdir -p input/"$year"
2021-07-14 13:50:33 -07:00
for day in {1..25}; do
if [[ day -lt 10 ]]; then
d="0$day"
else
d="$day"
fi
url="https://adventofcode.com/$year/day/$day/input"
2024-08-13 08:32:35 -07:00
get "$1" "$url" "input/$year/$d"
2021-07-14 13:50:33 -07:00
done
2022-09-09 11:13:53 -07:00
touch "input/$year/test"
2021-07-14 13:50:33 -07:00
done