Add 'locate' endpoint to borrow API#9842
Merged
mekarpeles merged 3 commits intoSep 5, 2024
Merged
Conversation
Add a new endpoint to redirect to a worldcat page based on identifier data provided for a given edition. Prioritizes oclc, then isbn 13, isbn 10, and finally title.
mekarpeles
reviewed
Sep 5, 2024
| if edition.get('oclc_numbers', None): | ||
| redirect_url += f'title/{edition.oclc_numbers[0]}' | ||
| elif edition.get('isbn_13', edition.get('isbn_10', None)): | ||
| redirect_url += f'isbn/{edition.isbn_13[0] or edition.isbn_10[0]}' |
Member
There was a problem hiding this comment.
This is problematic because in line 205 we check whether isbn13 or isbn10 is available... But consider the case where there is an isbn10 but not an isbn13
In line 206, even though there's no isbn13, we're still trying to access the 0th element which doesn't exist.
Member
There was a problem hiding this comment.
Also, /isbn converts to /search on worldcat which isn't ideal, but it is what it is.
mekarpeles
reviewed
Sep 5, 2024
mekarpeles
reviewed
Sep 5, 2024
Member
|
Works nicely! https://testing.openlibrary.org/books/OL7826547M/A_Game_of_Thrones/borrow?action=locate Squashing & merging |
3 tasks
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.
Closes #9829
Feature. Adds a new endpoint to redirect to a worldcat page based on identifier data provided for a given edition. Prioritizes oclc, then isbn 13, isbn 10, and finally title.
Technical
Adds an extra check to the
plugins/upstream/borrow.pyborrow class. If the endpoint /books/{olid}/{title}/borrow is reached with the parameteraction=locate, a redirect URL is constructed and redirected to.Testing
/borrow?action=locateto the end of the urlScreenshot
Stakeholders
@mekarpeles