ArmindoFlores / ao3_api

An unofficial archiveofourown.org (AO3) API for python
MIT License
166 stars 64 forks source link

Session.bookmarks gives index error if username capitalization is not correct #79

Closed TheElementalOfDestruction closed 1 year ago

TheElementalOfDestruction commented 1 year ago
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python39\lib\functools.py", line 969, in __get__
    val = self.func(instance)
  File "C:\Program Files\Python39\lib\site-packages\AO3\session.py", line 507, in bookmarks
    n = span.split(" ")[1]
IndexError: list index out of range

This was a weird one to diagnose, but I was able to determine the issue by messing around with the URL in my browser. When logging in to my session, I was able to successfully login with one of the letters in my username being capitalized where it isn't on the archive, so I didn't notice any issues until I tried to get the number of bookmarks.

Say for instance you have the username Test_user, and you enter your login details as Test_User, this will work fine and you won't encounter issues on the site. If you then go to the bookmarks page using Test_user as the username, it shows up as you would expect, with the bookmarks tab selected in the navigation. However, if you go using Test_User, then the navigation will not have the bookmarks selected, despite showing your bookmarks.