resolve author from work, add subtitle to title (ol)
This commit is contained in:
parent
0d77cfd158
commit
2749f22703
1 changed files with 11 additions and 1 deletions
|
@ -86,10 +86,18 @@ def lookup(id, return_all=False):
|
|||
|
||||
def format(info, return_all=False):
|
||||
data = {}
|
||||
if 'works' in info:
|
||||
work = api.get(info['works'][0]['key'])['result']
|
||||
else:
|
||||
work = None
|
||||
for key in KEYS:
|
||||
if key in info:
|
||||
value = info[key]
|
||||
if key == 'authors':
|
||||
if work:
|
||||
value = resolve_names([r['author']
|
||||
for r in work['authors'] if r['type']['key'] == '/type/author_role'])
|
||||
else:
|
||||
value = resolve_names(value)
|
||||
elif key == 'publish_country':
|
||||
value = value.strip()
|
||||
|
@ -107,6 +115,8 @@ def format(info, return_all=False):
|
|||
elif isinstance(value, list) and key not in ('publish_places', 'lccn', 'oclc_numbers'):
|
||||
value = value[0]
|
||||
data[KEYS[key]] = value
|
||||
if 'subtitle' in info:
|
||||
data['title'] += ' ' + info['subtitle']
|
||||
if 'classification' in data:
|
||||
value = data['classification']
|
||||
if isinstance(value, list):
|
||||
|
|
Loading…
Reference in a new issue