-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetInput
More file actions
executable file
·15 lines (12 loc) · 777 Bytes
/
Copy pathgetInput
File metadata and controls
executable file
·15 lines (12 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/zsh
# set TZ so that we get the correct day within the first 24 hours of the published puzzle
export TZ=America/New_York
# The URL uses un-padded day numbers, but we need 0-padded day numbers for the output file.
id=${1:-$(date '+%-d')}
od=${2:-$(date '+%d')}
# the input is not the same for all participants, and we thus have to pass our session cookie value.
# HTTPie supports storing and using session context (incl. cookies) in a JSON file. If you need to
# renew the cookie, simply log into the web site, then copy the session cookie value from the
# "Storage" tab of "Web Developer Tools" into the session file.
https --download --quiet --output "input/Day$od" --session-read-only=2022 \
"https://adventofcode.com/2022/day/$id/input" && git add "input/Day$od"