-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_zenodo.py
More file actions
30 lines (24 loc) · 862 Bytes
/
Copy pathsync_zenodo.py
File metadata and controls
30 lines (24 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
from datetime import datetime
with open('zenodo_response.json') as f:
data = json.load(f)
hits = data.get('hits', {}).get('hits', [])
total = data.get('hits', {}).get('total', 0)
lines = [
'# BCT Programme - Zenodo DOI Registry',
'',
'Auto-updated: ' + datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC'),
'',
'Total records: ' + str(total),
'',
'| DOI | Title | Date |',
'|-----|-------|------|',
]
for hit in hits:
doi = hit.get('doi', 'N/A')
title = hit.get('metadata', {}).get('title', 'Untitled').replace('|', '-')[:80]
date = hit.get('metadata', {}).get('publication_date', '')
lines.append('| [' + doi + '](https://doi.org/' + doi + ') | ' + title + ' | ' + date + ' |')
with open('ZENODO_DOIS.md', 'w') as f:
f.write('\n'.join(lines))
print('Written ' + str(len(hits)) + ' records')