The swiss army knife of lossless video/audio editing
allow importing csv with 2 columns #2412
Mikael Finstad250506ce4ff0
diff --git a/src/renderer/src/edlFormats.test.ts b/src/renderer/src/edlFormats.test.tsindex 9e929bdd..3fdb2b2b 100644--- a/src/renderer/src/edlFormats.test.ts+++ b/src/renderer/src/edlFormats.test.ts@@ -244,6 +244,15 @@ it('parses csv with timestamps', async () => {]);});+it('parses csv with 2 only columns', async () => {+ const parsed = await parseCsv('1,2\n3,4\n', parseCsvTime);++ expect(parsed).toEqual([+ { start: 1, end: 2 },+ { start: 3, end: 4 },+ ]);+});+const cutlistStr = `[General]Application=SomeApplication.exediff --git a/src/renderer/src/edlFormats.ts b/src/renderer/src/edlFormats.tsindex c08945ab..2c4613aa 100644--- a/src/renderer/src/edlFormats.ts+++ b/src/renderer/src/edlFormats.ts@@ -47,16 +47,15 @@ export const getFrameValParser = (fps: number) => (str: string) => {};export async function parseCsv(csvStr: string, parseTimeFn: (a: string) => number | undefined) {- const rows = csvParse(csvStr, {}) as [string, string, string][];+ const rows = csvParse(csvStr, {}) as ([string, string] | [string, string, string])[];if (rows.length === 0) throw new Error(i18n.t('No rows found'));- if (!rows.every((row) => row.length === 3)) throw new Error(i18n.t('One or more rows does not have 3 columns'));-- const mapped = rows- .map(([start, end, name]) => ({- start: parseTimeFn(start) ?? 0,- end: parseTimeFn(end),- name: name.trim(),- }));+ if (!rows.every((row) => row.length >= 2 && row.length <= 3)) throw new Error(i18n.t('One or more rows does not have 3 columns'));++ const mapped = rows.map(([start, end, name]) => ({+ start: parseTimeFn(start) ?? 0,+ end: parseTimeFn(end),+ name: name?.trim(),+ }));if (!mapped.every(({ start, end }) => (!Number.isNaN(start)