-
Notifications
You must be signed in to change notification settings - Fork 0
/
bib.js
executable file
·127 lines (120 loc) · 2.06 KB
/
bib.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env node
import yaml from 'yaml'
import got from 'got'
import { argv } from 'process'
const props = new Set([
"type",
"id",
"citation-key",
"categories",
"language",
"journalAbbreviation",
"shortTitle",
"author",
"chair",
"collection-editor",
"compiler",
"composer",
"container-author",
"contributor",
"curator",
"director",
"editor",
"editorial-director",
"executive-producer",
"guest",
"host",
"interviewer",
"illustrator",
"narrator",
"organizer",
"original-author",
"performer",
"producer",
"recipient",
"reviewed-author",
"script-writer",
"series-creator",
"translator",
"accessed",
"available-date",
"event-date",
"issued",
"original-date",
"submitted",
"abstract",
"annote",
"archive",
"archive_collection",
"archive_location",
"archive-place",
"authority",
"call-number",
"chapter-number",
"citation-number",
"citation-label",
"collection-number",
"collection-title",
"container-title",
"container-title-short",
"dimensions",
"division",
"DOI",
"edition",
"event",
"event-title",
"event-place",
"first-reference-note-number",
"genre",
"ISBN",
"ISSN",
"issue",
"jurisdiction",
"keyword",
"locator",
"medium",
"note",
"number",
"number-of-pages",
"number-of-volumes",
"original-publisher",
"original-publisher-place",
"original-title",
"page",
"page-first",
"part",
"part-title",
"PMCID",
"PMID",
"printing",
"publisher",
"publisher-place",
"references",
"reviewed-genre",
"reviewed-title",
"scale",
"section",
"source",
"status",
"supplement",
"title",
"title-short",
"URL",
"version",
"volume",
"volume-title",
"volume-title-short",
"year-suffix"
])
const DOI = argv[2]
const res = await got.get(`https://dx.doi.org/${DOI}`,{
headers: {
Accept: 'application/citeproc+json',
}
})
const item = JSON.parse(res.body)
const keys = Object.keys(item).filter(x => props.has(x))
const result = { DOI }
keys.forEach(k => result[k] = item[k])
console.log(yaml.stringify([result],{
}))