Skip to content

Commit

Permalink
Close #5 - Add year input
Browse files Browse the repository at this point in the history
  • Loading branch information
J0B10 committed Oct 9, 2021
1 parent ed639df commit be74e51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion aoc-badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
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')
id = os.getenv('INPUT_USERID')
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 }
Expand Down

0 comments on commit be74e51

Please sign in to comment.