|
|
|
@ -71,37 +71,38 @@ export async function parseCsv(csvStr: string, parseTimeFn: (a: string) => numbe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function parseCutlist(clStr: string) {
|
|
|
|
export async function parseCutlist(clStr: string) {
|
|
|
|
|
|
|
|
|
|
|
|
// first parse INI-File into "iniValue" object
|
|
|
|
// first parse INI-File into "iniValue" object
|
|
|
|
const regex = {
|
|
|
|
const regex = {
|
|
|
|
section: /^\s*\[\s*([^\]]*)\s*\]\s*$/,
|
|
|
|
section: /^\s*\[\s*([^\]]*)\s*]\s*$/,
|
|
|
|
param: /^\s*([^=]+?)\s*=\s*(.*?)\s*$/,
|
|
|
|
param: /^\s*([^=]+?)\s*=\s*(.*?)\s*$/,
|
|
|
|
comment: /^\s*;.*$/
|
|
|
|
comment: /^\s*;.*$/,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const iniValue = {};
|
|
|
|
const iniValue = {};
|
|
|
|
const lines = clStr.split(/[\r\n]+/);
|
|
|
|
const lines = clStr.split(/[\n\r]+/);
|
|
|
|
let section:string|null|undefined = null;
|
|
|
|
let section:string|null|undefined = null;
|
|
|
|
lines.forEach(function(line){
|
|
|
|
lines.forEach((line) => {
|
|
|
|
if(regex.comment.test(line)){
|
|
|
|
if (regex.comment.test(line)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}else if(regex.param.test(line)){
|
|
|
|
} if (regex.param.test(line)) {
|
|
|
|
const match = line.match(regex.param) || [];
|
|
|
|
const match = line.match(regex.param) || [];
|
|
|
|
if(match[1]){
|
|
|
|
const [, m1, m2] = match;
|
|
|
|
if(section){
|
|
|
|
if (m1) {
|
|
|
|
iniValue[section][match[1]] = match[2];
|
|
|
|
if (section) {
|
|
|
|
}else{
|
|
|
|
iniValue[section][m1] = m2;
|
|
|
|
iniValue[match[1]] = match[2];
|
|
|
|
} else {
|
|
|
|
|
|
|
|
iniValue[m1] = m2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(regex.section.test(line)){
|
|
|
|
} else if (regex.section.test(line)) {
|
|
|
|
const match = line.match(regex.section) || [];
|
|
|
|
const match = line.match(regex.section) || [];
|
|
|
|
if(match[1]){
|
|
|
|
const [, m1] = match;
|
|
|
|
iniValue[match[1]] = {};
|
|
|
|
if (m1) {
|
|
|
|
section = match[1];
|
|
|
|
iniValue[m1] = {};
|
|
|
|
|
|
|
|
section = m1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(line.length == 0 && section){
|
|
|
|
} else if (line.length === 0 && section) {
|
|
|
|
section = null;
|
|
|
|
section = null;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// end INI-File parse
|
|
|
|
// end INI-File parse
|
|
|
|
@ -109,20 +110,20 @@ export async function parseCutlist(clStr: string) {
|
|
|
|
let found = true;
|
|
|
|
let found = true;
|
|
|
|
let i = 0;
|
|
|
|
let i = 0;
|
|
|
|
const cutArr:{start:number, end:number, name:string}[] = [];
|
|
|
|
const cutArr:{start:number, end:number, name:string}[] = [];
|
|
|
|
while(found) {
|
|
|
|
while (found) {
|
|
|
|
const cutEntry = iniValue['Cut'+i];
|
|
|
|
const cutEntry = iniValue[`Cut${i}`];
|
|
|
|
if (cutEntry) {
|
|
|
|
if (cutEntry) {
|
|
|
|
const start = parseFloat(cutEntry.Start);
|
|
|
|
const start = parseFloat(cutEntry.Start);
|
|
|
|
const end = Math.round((start + parseFloat(cutEntry.Duration) + Number.EPSILON) * 100) / 100
|
|
|
|
const end = Math.round((start + parseFloat(cutEntry.Duration) + Number.EPSILON) * 100) / 100;
|
|
|
|
cutArr.push({
|
|
|
|
cutArr.push({
|
|
|
|
start: start,
|
|
|
|
start,
|
|
|
|
end: end,
|
|
|
|
end,
|
|
|
|
name: `Cut ${i}`,
|
|
|
|
name: `Cut ${i}`,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
found = false;
|
|
|
|
found = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cutArr.every(({ start, end }) => (
|
|
|
|
if (!cutArr.every(({ start, end }) => (
|
|
|
|
|