From a1e953004af421310fa9e1769701e147d69d209a Mon Sep 17 00:00:00 2001 From: Pawween Date: Tue, 15 Oct 2024 14:26:53 +0000 Subject: [PATCH] fixed IndexError --- stages/python/02_download.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stages/python/02_download.py b/stages/python/02_download.py index 309c441..375d82f 100644 --- a/stages/python/02_download.py +++ b/stages/python/02_download.py @@ -35,10 +35,11 @@ def extract_metadata(doi): if response.status_code == 200: data = response.json()['message'] title = data.get('title', [None])[0] - journal = data.get('container-title', [None])[0] + journal = data.get('container-title', []) + journal = journal[0] if journal else None authors = data.get('author', []) all_authors = ', '.join([f"{author['given']} {author['family']}" for author in authors]) if authors else None - return {'title': title, 'journal': journal, 'author': all_authorsauthor} + return {'title': title, 'journal': journal, 'author': all_authors} return {'title': None, 'journal': None, 'author': None} input_dir = Path('brick')