Repository: internetarchive/openlibrary

Issue:
Importing from IA sometimes results in `pagination`/`physical_dimensions` in `description`
Some imports from IA result in data being put in the edition description that should be in the `pagination` or `physical_dimensions` field.

### Evidence / Screenshot (if possible)
![image](https://github.com/internetarchive/openlibrary/assets/6251786/311a68c8-ce69-4710-8c10-153f0cd9737f)

https://openlibrary.org/books/OL27806251M/Blood_Rites?_compare=Compare&b=5&a=4&m=diff

https://archive.org/details/beyondvisionstor0000nola , https://openlibrary.org/books/OL43049076M/Beyond_vision

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: Data is in `description`
* Expected: data is in `pagination` and `physical_dimensions`


### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
@scottbarnes @seabelis @hornc 

Importing from IA sometimes results in `pagination`/`physical_dimensions` in `description`
Some imports from IA result in data being put in the edition description that should be in the `pagination` or `physical_dimensions` field.

### Evidence / Screenshot (if possible)
![image](https://github.com/internetarchive/openlibrary/assets/6251786/311a68c8-ce69-4710-8c10-153f0cd9737f)

https://openlibrary.org/books/OL27806251M/Blood_Rites?_compare=Compare&b=5&a=4&m=diff

https://archive.org/details/beyondvisionstor0000nola , https://openlibrary.org/books/OL43049076M/Beyond_vision

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: Data is in `description`
* Expected: data is in `pagination` and `physical_dimensions`


### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
@scottbarnes @seabelis @hornc 



Discussion:

Resolving patch:
diff --git a/openlibrary/plugins/importapi/code.py b/openlibrary/plugins/importapi/code.py
--- a/openlibrary/plugins/importapi/code.py
+++ b/openlibrary/plugins/importapi/code.py
@@ -197,30 +197,17 @@ def ia_import(
         """
         from_marc_record = False
 
-        # Case 1 - Is this a valid Archive.org item?
+        # Check 1 - Is this a valid Archive.org item?
         metadata = ia.get_metadata(identifier)
         if not metadata:
-            raise BookImportError('invalid-ia-identifier', '%s not found' % identifier)
-
-        # Case 2 - Does the item have an openlibrary field specified?
-        # 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.
-        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'] = edition_olid
-            edition_data = cls.populate_edition_data(edition_data, identifier)
-            return cls.load_book(edition_data)
+            raise BookImportError('invalid-ia-identifier', f'{identifier} not found')
 
-        # Case 3 - Can the item be loaded into Open Library?
+        # Check 2 - Can the item be loaded into Open Library?
         status = ia.get_item_status(identifier, metadata)
         if status != 'ok' and not force_import:
-            raise BookImportError(status, 'Prohibited Item %s' % identifier)
+            raise BookImportError(status, f'Prohibited Item {identifier}')
 
-        # Case 4 - Does this item have a marc record?
+        # Check 3 - Does this item have a MARC record?
         marc_record = get_marc_record_from_ia(
             identifier=identifier, ia_metadata=metadata
         )
@@ -234,9 +221,7 @@ def ia_import(
             try:
                 edition_data = read_edition(marc_record)
             except MarcException as e:
-                logger.error(
-                    'failed to read from MARC record %s: %s', identifier, str(e)
-                )
+                logger.error(f'failed to read from MARC record {identifier}: {e}')
                 raise BookImportError('invalid-marc-record')
         else:
             try:
@@ -280,8 +265,8 @@ def POST(self):
                 rec = MarcBinary(data)
                 edition = read_edition(rec)
             except MarcException as e:
-                details = f"{identifier}: {e}"
-                logger.error("failed to read from bulk MARC record %s", details)
+                details = f'{identifier}: {e}'
+                logger.error(f'failed to read from bulk MARC record {details}')
                 return self.error('invalid-marc-record', details, **next_data)
 
             actual_length = int(rec.leader()[:MARC_LENGTH_POS])


Test patch: