-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdimu.js
78 lines (68 loc) · 2.68 KB
/
dimu.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
const axios = require('axios');
const turf = require('@turf/turf');
const BASE_URL = "https://api.dimu.org";
module.exports = {
async getImagesDigitaltMuseum(topic) {
//construct query
const requestConfig = {
baseURL: BASE_URL + "/",
url: "/api/solr/",
method: "get",
params: {
q: topic,
wt: json,
api.key: demo,
}
}
const response = await axios.request(requestConfig);
let images = [];
if (!response.data.records) {
return [];
}
//format response
for (var i = 0; i < response.data.records.length; i++) {
var record = response.data.records[i];
if (record.images != undefined && record.images.length > 0) {
//assign data to metadata properties
var image = {
id: artifact.uuid,
// source: result.source,
title: artifact.ingress.title,
// imageURL: result.url,
// thumbURL: result.thumbnail,
// download_url: result.detail,
creators: artifact.ingress.producer,
creator_roles: artifact.ingress.producerRole, //new
// creator_urls: result.creator_url,
institutions: identifier.owner,
subjects: artifact.ingress.subjects,
// legacy_tags: result.legacy_tags,
license: artifact.ingress.license,
// license_id: result.license,
// license_version: result.license_version,
// license_link: '',
// infoURL: result.foreign_landing_url,
inventoryNumber: identifier.id,
geoLocations: artifact.coordinate,
measurements: artifact.defaultPictureDimension,
formats: artifact.type,
year: artifact.ingress.production.fromYear,
year_end: artifact.ingress.production.toYear, //new
// publisher: '',
// actors: '',
places: artifact.ingress.production.place,
// collection: '',
// imageRights: '',
// description: '',
// inscriptions: '',
datecreated: artifact.publishedDate
}
images.push(image);
}
}
if (images.length > 30) { // Good practice
images = images.slice(0, 30);
}
return images;
}
};