Add tool to fetch inputs
Signed-off-by: AKU <tom@tdpain.net>
This commit is contained in:
parent
59ed9b27d2
commit
75d6ceb8b6
2 changed files with 29 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -252,4 +252,5 @@ dmypy.json
|
|||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/go,python,jetbrains+all
|
||||
|
||||
input.txt
|
||||
input.txt
|
||||
input-loader.json
|
27
get-input.py
Normal file
27
get-input.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import datetime
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
default_config_file_name = os.path.join(script_dir, "input-loader.json")
|
||||
|
||||
today = datetime.date.today()
|
||||
|
||||
parser = argparse.ArgumentParser(description='Process some integers.')
|
||||
parser.add_argument('--config-file', dest="config_file", default=default_config_file_name, help='config file name')
|
||||
parser.add_argument('--day', default=today.day, help='day to get input for')
|
||||
parser.add_argument('--year', default=today.year, help='year to get input for')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.config_file) as f:
|
||||
config_data = json.load(f)
|
||||
|
||||
r = requests.get(f"https://adventofcode.com/{args.year}/day/{args.day}/input", cookies={"session": config_data["session"]})
|
||||
|
||||
sys.stdout.write(r.text + "\n")
|
||||
|
||||
sys.stderr.write("OK\n")
|
Loading…
Add table
Add a link
Reference in a new issue