Repository: wimglenn/advent-of-code-data

Issue:
User.get_stats() throws an error if no stars have been collected for a year
The source of the `https://adventofcode.com/{year}/leaderboard/self` does not include an `article` tag which causes an exception:

```python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jokajak/.cache/pypoetry/virtualenvs/aoc-coTrba3t-py3.10/lib/python3.10/site-packages/aocd/models.py", line 113, in get_stats
    if soup.article.pre is None and "overall leaderboard" in soup.article.text:
AttributeError: 'NoneType' object has no attribute 'pre'
```

Discussion:

Patch:
diff --git a/aocd/models.py b/aocd/models.py
index 40ad494..514d7c3 100644
--- a/aocd/models.py
+++ b/aocd/models.py
@@ -110,6 +110,8 @@ class User(object):
             response = requests.get(url, cookies=self.auth, headers=USER_AGENT)
             response.raise_for_status()
             soup = bs4.BeautifulSoup(response.text, "html.parser")
+            if soup.article is None and "You haven't collected any stars" in soup.main.text:
+                continue
             if soup.article.pre is None and "overall leaderboard" in soup.article.text:
                 msg = "the auth token ...{} is expired or not functioning"
                 raise DeadTokenError(msg.format(self.token[-4:]))
diff --git a/aocd/version.py b/aocd/version.py
index c68196d..a955fda 100644
--- a/aocd/version.py
+++ b/aocd/version.py
@@ -1,1 +1,1 @@
-__version__ = "1.2.0"
+__version__ = "1.2.1"


Test patch:
diff --git a/tests/test_models.py b/tests/test_models.py
index 463d3d5..435c9ca 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -228,13 +228,22 @@ def test_get_stats_when_token_expired(requests_mock):
     user = User("token12345678")
     requests_mock.get(
         url="https://adventofcode.com/2019/leaderboard/self",
-        text="<article><p>Below is the <em>Advent of Code 2021</em> overall leaderboard</p></article>"
+        text="<article><p>Below is the <em>Advent of Code 2019</em> overall leaderboard</p></article>"
     )
     expected_msg = "the auth token ...5678 is expired or not functioning"
     with pytest.raises(DeadTokenError(expected_msg)):
         user.get_stats(years=[2019])
 
 
+def test_get_stats_when_no_stars_yet(requests_mock):
+    user = User("token12345678")
+    requests_mock.get(
+        url="https://adventofcode.com/2019/leaderboard/self",
+        text="<main>You haven't collected any stars... yet.</main>"
+    )
+    assert user.get_stats(years=[2019]) == {}
+
+
 def test_get_stats_slow_user(requests_mock):
     puzzle = Puzzle(year=2019, day=25)
     requests_mock.get(