Load new fields via connector

This commit is contained in:
Mouse Reeve 2022-01-30 11:41:33 -08:00
parent c4b8e7949d
commit 44dad43f36

View file

@ -68,7 +68,26 @@ class Connector(AbstractConnector):
Mapping("born", remote_field="birth_date"),
Mapping("died", remote_field="death_date"),
Mapping("bio", formatter=get_description),
Mapping("isni", remote_field="remote_ids", formatter=get_isni),
Mapping(
"isni",
remote_field="remote_ids",
formatter=lambda b: get_dict_field(b, "isni"),
),
Mapping(
"asin",
remote_field="remote_ids",
formatter=lambda b: get_dict_field(b, "amazon"),
),
Mapping(
"viaf",
remote_field="remote_ids",
formatter=lambda b: get_dict_field(b, "viaf"),
),
Mapping(
"wikidata",
remote_field="remote_ids",
formatter=lambda b: get_dict_field(b, "wikidata"),
),
]
def get_book_data(self, remote_id):
@ -227,11 +246,11 @@ def get_languages(language_blob):
return langs
def get_isni(remote_ids_blob):
def get_dict_field(blob, field_name):
"""extract the isni from the remote id data for the author"""
if not remote_ids_blob or not isinstance(remote_ids_blob, dict):
if not blob or not isinstance(blob, dict):
return None
return remote_ids_blob.get("isni")
return blob.get(field_name)
def pick_default_edition(options):