-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheuropeana.js
More file actions
139 lines (121 loc) · 4.84 KB
/
europeana.js
File metadata and controls
139 lines (121 loc) · 4.84 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
const axios = require('axios');
const turf = require('@turf/turf');
const BASE_URL = "https://api.europeana.eu/record/v2/search.json";
if (process.env.EUROPEANA_API_KEY == undefined) {
console.log("Set environment variable EUROPEANA_API_KEY to your EUROPEANA API key.");
}
module.exports = {
async getImagesEuropeana(topic,language) {
let query = '"' + JSON.parse(topic).join('" OR "') + '"';
const requestConfig = {
baseURL: BASE_URL + "/",
params: {
wskey: process.env.EUROPEANA_API_KEY,
query: query,
qf: '',
media: true,
thumbnail: true,
sort: 'timestamp_created',
rows: 100
}
}
const response = await axios.request(requestConfig);
let images = [];
if (!response.data.items) {
return [];
}
//format response
for (var i = 0; i < response.data.items.length; i++) {
var item = response.data.items[i];
var image = {
id: item.id,
source: 'Europeana',
title: [], //dcTitleLangAware
description: item.dcDescription,//dcDescriptionLangAware/langcode
imageURL: item.edmIsShownBy,
thumbURL: item.edmPreview[0],
//download_url: result.detail,
creators: [],
institutions: [],
subjects: item.subject,
//legacy_tags: result.legacy_tags,
license: '',
license_id: '',
//license_version: result.license_version,
license_link: item.rights[0],
rightsstatement: '',
infoURL: '',
inventoryNumber: '',
geoLocations: '',//transformation FIX
measurements: '',
formats: '',
year: '',
publisher: '',
actors: item.edmAgent,
places: item.edmPlaceLabel,//.def = language
collection: '',
imageRights: '',
inscriptions: '',
datecreated: item.when,
language: ''
}
if (item.year) {
image.year = item.year[0];
}
if (!!item.edmIsShownAt && item.edmIsShownAt.length > 0) {
image.infoURL = item.edmIsShownAt[0];
}
if (!!item.title && item.title.length > 0) {
for (let title of item.title) {
image.title.push(title);
}
}
if (item.dcCreator) {
for (let creator of item.dcCreator) {
image.creators.push(creator);
}
}
if (item.dataProvider) {
for (let provider of item.dataProvider) {
image.institutions.push(provider);
}
}
if (!!item.rights && item.rights > 0) {
switch (item.rights) {
case "http://creativecommons.org/licenses/by/4.0":
license = "CC BY 4.0";
license_id = "CC BY 4.0";
case "http://creativecommons.org/licenses/by-sa/4.0":
license = "CC BY-SA 4.0";
license_id = "CC BY-SA 4.0";
case "http://creativecommons.org/licenses/by-nc/4.0":
license = "CC BY-NC 4.0";
license_id = "CC BY-NC 4.0";
case "http://creativecommons.org/licenses/by-nd/4.0":
license = "CC BY-ND 4.0";
license_id = "CC BY-ND 4.0";
case "http://creativecommons.org/licenses/by-nc-sa/4.0":
license = "CC BY-NC-SA 4.0";
license_id = "CC BY-NC-SA 4.0";
case "http://creativecommons.org/licenses/by-nc-nd/4.0":
license = "CC BY-NC-ND 4.0";
license_id = "CC BY-NC-ND 4.0";
case "http://creativecommons.org/publicdomain/mark/1.0/":
license = "CC0";
license_id = "CC0";
case "http://rightsstatements.org/vocab/InC/1.0/":
rightsstatement = "In copyright";
case "http://rightsstatements.org/vocab/NoC-OKLR/1.0/":
rightsstatement = "Other legal restrictions";
}
}
if (!!item.type && item.type > 0) {
for (let type of item.type) {
image.formats.push(type);
}
}
images.push(image);
}
return images;
}
};