mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Add automated download script
This commit is contained in:
26
2020/download.sh
Executable file
26
2020/download.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z $AOC_SESSION ]]; then
|
||||||
|
echo "AOC_SESSION not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $# -ge 1 ]]; then
|
||||||
|
# Get rid of leading zeroes
|
||||||
|
(( DAY = $1 * 1 ))
|
||||||
|
else
|
||||||
|
DAY=$(date +%-d)
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGET_FILE=$(printf "inputs/%02d.txt" "$DAY")
|
||||||
|
|
||||||
|
echo "Going to download day $DAY to $TARGET_FILE"
|
||||||
|
|
||||||
|
if [[ -s $TARGET_FILE ]]; then
|
||||||
|
echo "Target file exists"
|
||||||
|
else
|
||||||
|
curl --output "$TARGET_FILE" \
|
||||||
|
--header "Cookie: session=$AOC_SESSION" \
|
||||||
|
--fail \
|
||||||
|
"https://adventofcode.com/2020/day/$DAY/input"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user