76 json_data = resp.json()
78 for result
in json_data.get(
'results', []):
80 if not result.get(
'title'):
87 doi = result.get(
'doi')
89 url = f
'https://doi.org/{doi}'
91 if url
is None and result.get(
'doi'):
93 url =
'https://doi.org/' + str(result[
'doi'])
94 elif result.get(
'id'):
95 url =
'https://core.ac.uk/works/' + str(result[
'id'])
96 elif result.get(
'downloadUrl'):
97 url = result[
'downloadUrl']
98 elif result.get(
'sourceFulltextUrls'):
99 url = result[
'sourceFulltextUrls']
104 published_date =
None
106 raw_date = result.get(
'publishedDate')
or result.get(
'depositedDate')
109 published_date = datetime.fromisoformat(result[
'publishedDate'].replace(
'Z',
'+00:00'))
110 except (ValueError, AttributeError):
115 if result.get(
'journals'):
116 journals = [j.get(
'title')
for j
in result[
'journals']
if j.get(
'title')]
119 publisher = result.get(
'publisher',
'').strip(
"'")
121 publisher = publisher.strip(
"'")
125 for i
in result.get(
'authors', []):
132 'template':
'paper.html',
133 'title': result.get(
'title'),
135 'content': result.get(
'fullText',
'')
or '',
137 'tags': result.get(
'fieldOfStudy', []),
138 'publishedDate': published_date,
139 'type': result.get(
'documentType',
'')
or '',
141 'editor':
', '.join(result.get(
'contributors', [])),
142 'publisher': publisher,
143 'journal':
', '.join(journals),
144 'doi': result.get(
'doi'),
147 'pdf_url': result.get(
'downloadUrl', {})
or result.get(
"sourceFulltextUrls", {}),