ArmindoFlores / ao3_api

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

Error if there are no series bookmarks #56

Closed searchtools-avi closed 3 years ago

searchtools-avi commented 3 years ago

This is an obscure case and very frustrating, in the latest 2.2.0 version.

If there are no bookmarks for a series, the label is not there either

<dt class="stats">Stats:</dt>
<dd class="stats">
<dl class="stats">
<dt>Words:</dt>
<dd>23,327</dd>
<dt>Works:</dt>
<dd>16</dd>
<dt>Complete:</dt>
<dd>No</dd>
</dl>
</dd>
</dl>

So when I ask for series.nbookmarks it returns this error: UnboundLocalError: local variable 'book' referenced before assignment

I tried to work around it, but my try... except Exception handling doesn't get the error very well, nor does hasattr(series, 'nbookmarks'). Could you fix this, preferably by returning 0?

Thanks

searchtools-avi commented 3 years ago

testable series: 1638784

ArmindoFlores commented 3 years ago

There's probably a couple more fields with this issue, I'm gonna do some more testing