Add current set of helper files.

This commit is contained in:
2023-12-27 21:43:13 -05:00
parent bbdfb62d3a
commit b88d839bc1
4 changed files with 329 additions and 0 deletions

25
get.py Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys
import requests
from keyring import get_password
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <year> <day>")
sys.exit(1)
year = sys.argv[1]
day = sys.argv[2]
session_cookie = get_password('aoc-session-cookie', 'felixm')
url = f"https://adventofcode.com/{year}/day/{day}/input"
cookies = {'session': session_cookie}
response = requests.get(url, cookies=cookies)
if response.status_code == 200:
filename = f"i{day}.txt"
with open(filename, 'w') as file:
file.write(response.text)
print(f"Year {year} {filename} written.")
else:
print(f"Error: Failed to download input (HTTP status code {response.status_code}).")