diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts index fe2b4f88..813fcd2f 100644 --- a/src/utils/exporter.ts +++ b/src/utils/exporter.ts @@ -35,7 +35,7 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[] const lines = data.split("\n"); const result: SponsorTime[] = []; for (const line of lines) { - const match = line.match(/(?:(\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g); + const match = line.match(/(?:((?:\d+:)?\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g); if (match) { const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]); if (startTime) { diff --git a/test/exporter.test.ts b/test/exporter.test.ts index dd589db1..3093d1b8 100644 --- a/test/exporter.test.ts +++ b/test/exporter.test.ts @@ -238,4 +238,20 @@ describe("Import segments", () => { category: "chapter" as Category }]); }); + + it ("22. 2:04:22 some name", () => { + const input = ` 22. 2:04:22 some name + 23. 2:04:22.23 some other name`; + + const result = importTimes(input, 8000); + expect(result).toMatchObject([{ + segment: [7462, 7462.23], + description: "some name", + category: "chapter" as Category + }, { + segment: [7462.23, 8000], + description: "some other name", + category: "chapter" as Category + }]); + }); }); \ No newline at end of file