commit 537dcc948cedddbb9da23c6201afa931643c1ee9 parent ad331c2d53221b485b74d495394a42dd8d99fc1d Author: Jack Sangdahl <jack@pngu.org> Date: Mon, 1 Dec 2025 16:21:09 +0100 chore: Tidy up data fetching script and use dotenv Diffstat:
| M | .gitignore | | | 1 | + |
| M | data.py | | | 15 | +++++++-------- |
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ .venv +.env diff --git a/data.py b/data.py @@ -1,16 +1,15 @@ -#!/bin/python3 -import time +import os import subprocess +import time from pathlib import Path -# [firefox] -# from https://adventofcode.com/2022/day/12/input or any input page -# right click > inspect accessibility properties > network > reload -# under "file", click "input" request > cookies > copy 'session' id -id = "53616c7465645f5fcd5b9a18a69a4ab874f367b422884a975cddb33dac42401df30be8e602ce986d28fe2502209d2d106254b106339e93608711d228ff22176d" +import dotenv + +dotenv.load_dotenv() +id = os.getenv("SESSION_ID") year = time.strftime("%Y") hour = time.strftime("%H") -day = int(time.strftime("%d")) + 1 +day = int(time.strftime("%d")) cmd = f'curl https://adventofcode.com/{year}/day/{day}/input --cookie "session={id}"' output = subprocess.check_output(cmd, shell=True) output = output.decode("utf-8")