-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c04faba
commit 5929211
Showing
1 changed file
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,20 @@ set -e | |
year="${AOC_YEAR:-$(date +%Y)}" | ||
month="${AOC_MONTH:-$(date +%m)}" | ||
day="${AOC_DAY:-$(date +%-d)}" | ||
padded_day="0$day" | ||
padded_day="${padded_day: -2}" | ||
|
||
if [[ ! "$month" -eq 12 ]]; then | ||
echo "It's not december quite yet. If you wish to access previous events" | ||
echo "specify AOC_YEAR, AOC_MONTH and AOC_DAY" | ||
exit 1 | ||
fi | ||
|
||
mkdir -p "$year/$day" | ||
mkdir -p "$year/$padded_day" | ||
|
||
export PATH="/usr/local/opt/[email protected]/bin:$PATH" | ||
session_cookie="$(security find-generic-password -w -a "com.adventofcode.SessionCookie")" | ||
curl --silent --cookie "session=$session_cookie" "https://adventofcode.com/$year/day/$day" | ./scripts/html2md.py > "$year/$day/README.md" | ||
curl --silent --cookie "session=$session_cookie" "https://adventofcode.com/$year/day/$day/input" > "$year/$day/input.txt" | ||
curl --silent --cookie "session=$session_cookie" "https://adventofcode.com/$year/day/$day" | ./scripts/html2md.py > "$year/$padded_day/README.md" | ||
curl --silent --cookie "session=$session_cookie" "https://adventofcode.com/$year/day/$day/input" > "$year/$padded_day/input.txt" | ||
|
||
echo "$day/12 $year initialized successfully in ./$year/$day" >&2 | ||
echo "$day/12 $year initialized successfully in ./$year/$padded_day" >&2 |