-
Notifications
You must be signed in to change notification settings - Fork 0
/
airtable.js
69 lines (57 loc) · 2.27 KB
/
airtable.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
// Dumps desired metadata for all oral histories into a /dump directory
var Airtable = require('airtable');
var fs = require('fs');
require('dotenv').config();
var dir = './dump';
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
var base = new Airtable({apiKey: process.env.APIKEY}).base(process.env.BASE);
base('Oral Histories').select({
// Selecting the first 3 records in Worksheet:
// maxRecords: 3,
view: ".LOCMetadataView",
cellFormat: "string",
timeZone: "America/New_York",
userLocale: "en-ca",
fields: [
"Identifier",
"Languages: ISO Code (639-3)",
"Languages: Speaker preferred names",
"Contributor: Speakers",
".self?",
"Contributor: Videographer",
"Coverage: Video Nation",
"Coverage: Video Territory",
"Description",
"video_license",
"Youtube Publish Date",
"Wikimedia Eligibility",
"wikimedia_commons_link"
]
}).eachPage(function page(records, fetchNextPage) {
// This function (`page`) will get called for each page of records.
records.forEach(function(record) {
const content = [`Metadata for ${record.get('Identifier')}
Oral History ID: ${record.get('Identifier')}
Languages by ISO 639-3 Code: ${record.get('Languages: ISO Code (639-3)')}
Language Names: ${record.get('Languages: Speaker preferred names')}
Speakers: ${record.get('Contributor: Speakers')}
Video Description: ${record.get('Description')}
Original Submitter: ${record.get('Contributor: Videographer')}
video_license: ${record.get('video_license')}
Coverage: Video Nation: ${record.get('Coverage: Video Nation')}
Coverage: Video Territory: ${record.get('Coverage: Video Territory')}
Published to Youtube on: ${record.get('Youtube Publish Date')}
Wikimedia Eligibility: ${record.get('Wikimedia Eligibility')}
wikimedia_commons_link: ${record.get('wikimedia_commons_link')}`]
fs.writeFileSync(`dump/${record.get('Identifier')}__metadata.txt`, content);
console.log('wrote', record.get('Identifier'));
});
// To fetch the next page of records, call `fetchNextPage`.
// If there are more records, `page` will get called again.
// If there are no more records, `done` will get called.
fetchNextPage();
}, function done(err) {
if (err) { console.error(err); return; }
});