diff options
author | cos <cos> | 2021-12-01 09:54:18 +0100 |
---|---|---|
committer | cos <cos> | 2021-12-01 09:54:18 +0100 |
commit | fe601d453f8b4c00dc12fd8945be0efffe9f8165 (patch) | |
tree | 7b09ce3da1bd1cdef7532aa2d05ee72d1fb3f3c1 | |
parent | d8118966d1070fecc700f3532ea139ccdcb9d894 (diff) | |
download | adventofcode-fe601d453f8b4c00dc12fd8945be0efffe9f8165.zip |
Minor changes to fetch_input
-rwxr-xr-x | bin/fetch_input.sh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/fetch_input.sh b/bin/fetch_input.sh index 3467871..6b27931 100755 --- a/bin/fetch_input.sh +++ b/bin/fetch_input.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh -eu COOKIES="${HOME}/.adventofcode.json" @@ -35,7 +35,9 @@ if [ "${MODE}" = 'wget' ]; then # https://stackoverflow.com/q/21919156/how-do-i-copy-cookies-from-chrome SESSION=$(jq < "${COOKIES}" '."session-cookie"' | tr -d '"') - [ -e "input" ] || { + if [ -e "input" ]; then + echo 'Directory input already exists. Skipping.' + else mkdir 'input' authenticated_wget --output-document "input/page_${DEC}.html" \ "https://adventofcode.com/${YEAR}/day/${DEC}" @@ -43,10 +45,11 @@ if [ "${MODE}" = 'wget' ]; then "https://adventofcode.com/${YEAR}/settings") USERNAME=$(echo "${SETTINGS}" | sed -n 's#.*display_name.*checked.*<span>\(.*\)</span>.*#\1#p') + echo "Found username: ${USERNAME}" authenticated_wget --output-document "input/${USERNAME}" \ "https://adventofcode.com/${YEAR}/day/${DEC}/input" elinks -dump "./input/page_${DEC}.html" >"input/page_${DEC}.txt" - } + fi elif [ "${MODE}" = 'aocdl' ]; then # One could possibly use the golang implemenation instead of wget: # https://github.com/GreenLightning/advent-of-code-downloader |