aboutsummaryrefslogtreecommitdiff
path: root/fetch-inputs
blob: f88583b9f39fcd34f76d5c70ddbb9b30a9825dad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

cd "$(dirname "$0")"

find .                                          \
	 -mindepth 2                                \
	 -maxdepth 2                                \
	 -type d                                    \
	 -regex '\./[0-9]\{4\}/[0-9]\{2\}'          \
	| sort                                      \
	| while IFS=/ read _ y d
do
	file=$y/$d/input
	[ -f "$file" ] && continue
	>&2 printf 'Fetching %s/%s... ' $y $d
	wget -q --load-cookies=.cookies -O "$file" \
		 "https://adventofcode.com/$y/day/${d#0}/input"
	>&2 printf 'DONE\n' >&2
done