Obtain person for attributedTo

main
Bob Mottram 2023-10-29 14:35:46 +00:00
parent f447293436
commit be4795f5c4
1 changed files with 9 additions and 0 deletions

View File

@ -52,6 +52,15 @@ def get_attributed_to(field) -> str:
if isinstance(field, str):
return field
elif isinstance(field, list):
for attrib in field:
if isinstance(attrib, dict):
if attrib.get('type') and attrib.get('id'):
if isinstance(attrib['type'], str) and \
isinstance(attrib['id'], str):
if attrib['type'] == 'Person' and \
'://' in attrib['id'] and \
'.' in attrib['id']:
return attrib['id']
if isinstance(field[0], str):
return field[0]
return None