Don't use the format detail if it maps directly
This commit is contained in:
parent
123b23728f
commit
0aef011258
|
@ -326,3 +326,11 @@ def infer_physical_format(format_text):
|
||||||
if not matches:
|
if not matches:
|
||||||
return None
|
return None
|
||||||
return matches[0]
|
return matches[0]
|
||||||
|
|
||||||
|
def unique_physical_format(format_text):
|
||||||
|
""" only store the format if it isn't diretly in the format mappings"""
|
||||||
|
format_text = format_text.lower()
|
||||||
|
if format_text in format_mappings:
|
||||||
|
# try a direct match, so saving this would be redundant
|
||||||
|
return None
|
||||||
|
return format_text
|
||||||
|
|
|
@ -3,7 +3,7 @@ import re
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from .abstract_connector import AbstractConnector, SearchResult, Mapping
|
from .abstract_connector import AbstractConnector, SearchResult, Mapping
|
||||||
from .abstract_connector import get_data, infer_physical_format
|
from .abstract_connector import get_data, infer_physical_format, unique_physical_format
|
||||||
from .connector_manager import ConnectorException
|
from .connector_manager import ConnectorException
|
||||||
from .openlibrary_languages import languages
|
from .openlibrary_languages import languages
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class Connector(AbstractConnector):
|
||||||
Mapping("publishedDate", remote_field="publish_date"),
|
Mapping("publishedDate", remote_field="publish_date"),
|
||||||
Mapping("pages", remote_field="number_of_pages"),
|
Mapping("pages", remote_field="number_of_pages"),
|
||||||
Mapping("physicalFormat", remote_field="physical_format", formatter=infer_physical_format),
|
Mapping("physicalFormat", remote_field="physical_format", formatter=infer_physical_format),
|
||||||
Mapping("physicalFormatDetail", remote_field="physical_format"),
|
Mapping("physicalFormatDetail", remote_field="physical_format", formatter=unique_physical_format),
|
||||||
Mapping("publishers"),
|
Mapping("publishers"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue