Files
aoc2020/open.sh
2020-12-13 07:16:50 +01:00

27 lines
707 B
Bash
Executable File

#!/bin/bash
day=$(date +'%-d')
day0=$(date +'%d')
time=$(date +'%H')
# /usr/bin/open https://adventofcode.com/2020/day/$day/input
mkdir -p day$day0/data/
cp module.py day$day0/
touch day$day0/data/sample.txt
current_epoch=$(date +%s)
if [ $time -gt 6 ]; then
day0=$(( $day0 + 1 ))
fi
target_epoch=$(date -j "12${day0}06002020.00" +%s)
echo "Sleep for $target_epoch - $current_epoch "
sleep_seconds=$(( $target_epoch - $current_epoch ))
echo "Sleep for $sleep_seconds"
sleep $sleep_seconds
day=$(date +'%-d')
day0=$(date +'%d')
curl -b cookies.txt https://adventofcode.com/2020/day/$day/input -o day$day0/data/data.txt
curl -b cookies.txt https://adventofcode.com/2020/day/$day -o day$day0/index.html