get_bookmarks from User#87
Open
encars28 wants to merge 3 commits into
Open
Conversation
This function returns a Series or a Work depending on the banner you pass.
Instead of calling get_work_from_banner now _load_bookmarks calls get_work_or_series_from_banner, so the bookmarks can be now a Work or a Series and the function doesn't cause errors when a series is passed instead of a work
Changed the get_work_from_banner function so it doesn't raise an error when we pass the banner of a external work
|
Can confirm this fixed it for me. Also fixes the error where some works either no longer exist or are Mystery. |
|
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:
to:
|
JuszieDragon
added a commit
to JuszieDragon/ao3_api
that referenced
this pull request
Mar 2, 2024
Added the changes from [this PR](wendytg#87) by encars28 in the [original repo](https://github.com/ArmindoFlores/ao3_api)
mcmanustfj
added a commit
to mcmanustfj/ao3_api
that referenced
this pull request
Dec 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.