-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add direct book providers #6585
Add direct book providers #6585
Conversation
openlibrary/templates/book_providers/direct_download_options.html
Outdated
Show resolved
Hide resolved
openlibrary/templates/book_providers/direct_download_options.html
Outdated
Show resolved
Hide resolved
e918d2d
to
14f9ffe
Compare
b27564b
to
ded8118
Compare
openlibrary/book_providers.py
Outdated
if edition.providers: | ||
return [EbookProvider.from_json(dict(p)) for p in edition.providers] | ||
else: | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if edition.providers: | |
return [EbookProvider.from_json(dict(p)) for p in edition.providers] | |
else: | |
return [] | |
return [EbookProvider.from_json(dict(p)) for p in edition.providers or []] |
fd52403
to
58fbdc1
Compare
cde216c
to
c287ad7
Compare
5fdb8c1
to
c7a3fcf
Compare
Notes from rebase: This code was in AffiliateLinks.html, to add the OPDS buy options to our buy options, but that code has since been updated to no longer take in $for provider in page.get('providers', []):
$if provider.get('rel') == 'http://opds-spec.org/acquisition/buy' and provider.get('href'):
$ name = provider.get('name', _('Official Vendor'))
$ href = provider.get('href')
$ price = provider.get('properties', {}).get('price', {}).get('value')
$if price:
$ price = '$%.2f' % price
$:affiliate_link('direct', 'direct', name, href, price) |
if ( | ||
action == "borrow" | ||
and (provider := get_book_provider(edition)) | ||
and (providers := provider.get_ebook_providers(edition)) | ||
and len(providers) >= 1 | ||
and providers[0].access == "open-access" | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for action="borrow" which is typically for borrowable books, but given most trusted book providers are for open access materials (and we tend to use "read" for these) we should make sure a case of /borrow?action=read also succeeds
7961494
to
8b806be
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6585 +/- ##
==========================================
+ Coverage 16.06% 16.21% +0.15%
==========================================
Files 90 90
Lines 4769 4786 +17
Branches 832 829 -3
==========================================
+ Hits 766 776 +10
- Misses 3480 3486 +6
- Partials 523 524 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woooohooooo!!! This is so close!! I think this last set of changes, and then merge it up to the github in the sky!
for more information, see https://pre-commit.ci
This reverts commit 152eec7.
Both `/borrow?action==borrow` and `/borrow?action==read` should succeed vis-a-vis web book access.
Query: is this something where the fix should occur upstream?
eb0b2f9
to
84bdb7d
Compare
Closes #9419
Test with
https://openlibrary.org/books/OL38222427M.json
What we want is:
On https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/borrow.py#L128C9-L128C40
Technical
Testing
Screenshot
Stakeholders