Skip to content

Commit efb4cd3

Browse files
committed
Attempt to fix Zenodo
Done by inspecting API responses - https://zenodo.org/api/records/3242074 - https://zenodo.org/api/records/3242074/files
1 parent de496f8 commit efb4cd3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

repo2docker/contentproviders/zenodo.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ def __init__(self):
2424
"http://sandbox.zenodo.org/record/",
2525
],
2626
"api": "https://sandbox.zenodo.org/api/records/",
27-
"filepath": "files",
28-
"filename": "filename",
29-
"download": "links.download",
27+
"files": "links.files",
28+
"filepath": "entries",
29+
"filename": "key",
30+
"download": "links.content",
3031
"type": "metadata.upload_type",
3132
},
3233
{
3334
"hostname": ["https://zenodo.org/record/", "http://zenodo.org/record/"],
3435
"api": "https://zenodo.org/api/records/",
35-
"filepath": "files",
36-
"filename": "filename",
37-
"download": "links.download",
36+
"files": "links.files",
37+
"filepath": "entries",
38+
"filename": "key",
39+
"download": "links.content",
3840
"type": "metadata.upload_type",
3941
},
4042
{
@@ -43,6 +45,7 @@ def __init__(self):
4345
"http://data.caltech.edu/records/",
4446
],
4547
"api": "https://data.caltech.edu/api/record/",
48+
"files": "",
4649
"filepath": "metadata.electronic_location_and_access",
4750
"filename": "electronic_name.0",
4851
"download": "uniform_resource_identifier",
@@ -69,9 +72,17 @@ def fetch(self, spec, output_dir, yield_output=False):
6972
f'{host["api"]}{record_id}',
7073
headers={"accept": "application/json"},
7174
)
72-
7375
record = resp.json()
7476

77+
if host["files"]:
78+
yield f"Fetching Zenodo record {record_id} files.\n"
79+
files_url = deep_get(record, host["files"])
80+
resp = self.urlopen(
81+
files_url,
82+
headers={"accept": "application/json"},
83+
)
84+
record = resp.json()
85+
7586
files = deep_get(record, host["filepath"])
7687
only_one_file = len(files) == 1
7788
for file_ref in files:

0 commit comments

Comments
 (0)