Skip to content

Commit

Permalink
import api: use edition ID from IA metadata if it exists (#8331)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbarnes authored Sep 28, 2023
1 parent eacde86 commit 24cad47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openlibrary/plugins/importapi/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ def ia_import(
# The scan operators search OL before loading the book and add the
# OL key if a match is found. We can trust them and attach the item
# to that edition.
if metadata.get('mediatype') == 'texts' and metadata.get('openlibrary'):
edition_olid = metadata.get('openlibrary_edition') or metadata.get(
'openlibrary'
)
if metadata.get('mediatype') == 'texts' and edition_olid:
edition_data = cls.get_ia_record(metadata)
edition_data['openlibrary'] = metadata['openlibrary']
edition_data['openlibrary'] = edition_olid
edition_data = cls.populate_edition_data(edition_data, identifier)
return cls.load_book(edition_data)

Expand Down

0 comments on commit 24cad47

Please sign in to comment.