ArmindoFlores / ao3_api

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

After searches, kudos/comments/bookmark counts only available if >0 #60

Open quihi opened 2 years ago

quihi commented 2 years ago

I noticed that when using the API to make searches, I can get the information that's in the banner (tags, summary, kudos count, etc.). However, since kudos, comments, and bookmarks are only listed in the banner if they are greater than 0, they are only stored if they are greater than 0. Otherwise, they're left at None, and if you try to access the property later, it crashes when it tries to find these in the page.

Do you think it is a reasonable solution to assign the kudos, comments, and bookmarks properties to 0, in the get_work_from_banner function, if they are not found in the banner? I can't think of any other cases where they wouldn't be listed, but I'm not sure if there is a reason it's best to leave it as is, and I shouldn't assume I can get this information without loading the fics.

quihi commented 2 years ago

Oh, and regardless of this, I will be putting in a small fix so the session used in a search is copied to the works in the search results.

ArmindoFlores commented 2 years ago

Do you think it is a reasonable solution to assign the kudos, comments, and bookmarks properties to 0, in the get_work_from_banner function, if they are not found in the banner?

At the time I didn't do it because I wasn't sure if there were cases where they wouldn't be shown, but also wouldn't be 0. It seems that there are no such cases and thus your proposal sounds very reasonable.