-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfcpxml-importer.js
30 lines (27 loc) · 1.1 KB
/
fcpxml-importer.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
async function parse() {
parser = new DOMParser();
xmlDoc = parser.parseFromString(await inputpicker.files[0].text(), "text/xml");
filename = await inputpicker.files[0].name;
// First we collect formats by their IDs (multiple clips may have same formats)
formati = {};
for (f of xmlDoc.getElementsByTagName("resources")[0].getElementsByTagName("format")) {
console.log(f);
id = f.getAttributeNode("id").value;
w = f.getAttributeNode("width").value;
h = f.getAttributeNode("height").value;
formati[id] = {};
formati[id]["w"] = w;
formati[id]["h"] = h;
}
// Now we collect clips and prepare an array of them to be passed to collage-maker.js
p = [];
for (a of xmlDoc.getElementsByTagName("resources")[0].getElementsByTagName("asset")) {
console.log(a);
name = a.getAttributeNode("name").value;
format = a.getAttributeNode("format").value;
width = formati[format]["w"];
height = formati[format]["h"];
p.push({"name": name, "width": width, "height": height});
}
return(p);
}