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 }