ArmindoFlores / ao3_api

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

get_bookmarks from User #87

Open encars28 opened 1 year ago

encars28 commented 1 year ago

This should fix #86

The problem was that when a series banner was passed to get_work_from_banner instead of a work, this condition is never true: elif a.attrs["href"].startswith("/works"):

This means that the workid is never initialized and there's an UnboundLocalError when we try to create a Work object. We can fix it by checking if the banner is the banner of a series or a work, so the get_work_from_banner is only called when we have a work and it doesn't raise that error.

This doesn't fix the problem completely, because mistery works and external works still raise an error. The external works problem can be fixed by changing the sintaxis of the condition that sets the workid, so that it is true for any string with "works/" in it, instead of strings that start with "/works". The mistery works problem can be fixed by checking the h4 tag before calling get_work_from_banner. This way, it skips the mistery works.

whitevegagabriel commented 1 year ago

Can confirm this fixed it for me. Also fixes the error where some works either no longer exist or are Mystery.

michaelkeenan commented 1 year ago

Thanks for solving this encars28!

I'm using it locally and I get "NameError: name 'get_work_or_series_from_banner' is not defined". I've fixed it by changing this:

from .common import get_work_from_banner

to:

from .common import get_work_from_banner, get_work_or_series_from_banner