From be74e5100549768bb5fe63222e1e4f26560ee611 Mon Sep 17 00:00:00 2001 From: Jonas <17405009+joblo2213@users.noreply.github.com> Date: Sat, 9 Oct 2021 09:58:20 +0200 Subject: [PATCH] Close #5 - Add year input --- action.yml | 5 +++++ aoc-badges.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 145d3b4..aaffc92 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,11 @@ inputs: description: > Your unique userid on adventofcode.com, obtain it from **YOUR** private leaderboard url (its the number at the end of the url). required: true + year: + description: > + The year for which the stats should be retrived. + If not speified, the current year (from system time) is used. + required: false leaderboard: description: > The url of your leaderboard json file. diff --git a/aoc-badges.py b/aoc-badges.py index f31c99b..1bd2d58 100644 --- a/aoc-badges.py +++ b/aoc-badges.py @@ -6,6 +6,7 @@ from datetime import date, timedelta # environment variables +year = os.getenv('INPUT_YEAR') leaderboard = os.getenv('INPUT_LEADERBOARD') session = os.getenv('INPUT_SESSION') readme = os.getenv('INPUT_FILE') @@ -13,8 +14,10 @@ day_regex = os.getenv('INPUT_DAYREGEX') stars_regex = os.getenv('INPUT_STARSREGEX') days_completed_regex = os.getenv('INPUT_DAYSCOMPLETEDREGEX') +if year is None or not leaderboard : + year = date.today().year if leaderboard is None or not leaderboard : - leaderboard = 'https://adventofcode.com/2020/leaderboard/private/view/' + id + ".json" + leaderboard = 'https://adventofcode.com/%s/leaderboard/private/view/%s.json' % (year, id) # fetch stars cookie = { 'session' : session }