www.fgks.org   »   [go: up one dir, main page]

Skip to content
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

Augment non-ISBN ASIN BWB records with BookWorm data #8903

Merged
Next Next commit
Don't write non-ISBN 10 ASINs to the isbn_10 field of a record
For books, Amazon usually returns ISBN 10s as its ASIN, but sometimes,
particularly in the case of ebooks, they may be numbers starting with
`B`, rather than ISBN 10s. This commit keeps the non-ISBN 10 ASIN in the
`source_records: ["amazon:asin"]` line, but prevents them from entering
the `isbn_10` field.

It also prevents `isbn_10` and `isbn_13` from having truthy `[None]`
values.
  • Loading branch information
scottbarnes committed Apr 17, 2024
commit 32645d958b2d161be1541547dd9a16bb0baef45f
7 changes: 5 additions & 2 deletions openlibrary/core/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ def serialize(product: Any) -> dict:
logger.exception(f"serialize({product})")
publish_date = None

asin_is_isbn10 = not product.asin.startswith("B")
isbn_13 = isbn_10_to_isbn_13(product.asin) if asin_is_isbn10 else None

book = {
'url': "https://www.amazon.com/dp/{}/?tag={}".format(
product.asin, h.affiliate_id('amazon')
),
'source_records': ['amazon:%s' % product.asin],
'isbn_10': [product.asin],
'isbn_13': [isbn_10_to_isbn_13(product.asin)],
'isbn_10': [product.asin] if asin_is_isbn10 else [],
'isbn_13': [isbn_13] if isbn_13 else [],
'price': price and price.display_amount,
'price_amt': price and price.amount and int(100 * price.amount),
'title': (
Expand Down