-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfetch.mjs
40 lines (30 loc) · 1.24 KB
/
fetch.mjs
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
import { writeFileSync } from 'fs';
import { join } from 'path';
import fetch from 'node-fetch';
const __dirname = new URL('.', import.meta.url).pathname;
function isWorkshop(talk) {
if (!talk.track) return false;
return talk.track.en === 'Workshop';
}
async function fetchMediaCCC() {
let mediaCCCLink = "https://api.media.ccc.de/public/conferences/nixcon2023";
let response = await fetch(mediaCCCLink);
let data = await response.json();
writeFileSync(join(__dirname, 'src/content/data/recordings.json'), JSON.stringify(data, null, 2));
}
async function fetchPretalx() {
let pretalxUrl = 'https://talks.nixcon.org/api/events/nixcon-2023/talks/';
let result = [];
while(pretalxUrl) {
let response = await fetch(pretalxUrl);
let data = await response.json();
pretalxUrl = data.next;
result = result.concat(data.results);
}
let workshops = result.filter(talk => isWorkshop(talk));
let talks = result.filter(talk => !isWorkshop(talk));
writeFileSync(join(__dirname, 'src/content/schedule/talks.json'), JSON.stringify(talks, null, 2));
writeFileSync(join(__dirname, 'src/content/schedule/workshops.json'), JSON.stringify(workshops, null, 2));
}
fetchPretalx();
fetchMediaCCC();