mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Don't remove trailing end bracket when not starting with bracket
This commit is contained in:
@@ -39,7 +39,8 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
|
|||||||
if (match) {
|
if (match) {
|
||||||
const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]);
|
const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]);
|
||||||
if (startTime !== null) {
|
if (startTime !== null) {
|
||||||
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:()\s]+$/g
|
// Remove "seconds", "at", special characters, and ")" if there was a "("
|
||||||
|
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:(\s]+$|(?<=^\s*\(.+)[-:()\s]*$/g
|
||||||
const titleLeft = line.split(match[0])[0].replace(specialCharsMatcher, "");
|
const titleLeft = line.split(match[0])[0].replace(specialCharsMatcher, "");
|
||||||
let titleRight = null;
|
let titleRight = null;
|
||||||
const split2 = line.split(match[1] || match[0]);
|
const split2 = line.split(match[1] || match[0]);
|
||||||
|
|||||||
@@ -275,4 +275,20 @@ describe("Import segments", () => {
|
|||||||
category: "chapter" as Category
|
category: "chapter" as Category
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it ("0:00 G¹ (Tangent Continuity)", () => {
|
||||||
|
const input = ` 0:00 G¹ (Tangent Continuity)
|
||||||
|
0:01 G² (Tangent Continuity)`;
|
||||||
|
|
||||||
|
const result = importTimes(input, 8000);
|
||||||
|
expect(result).toMatchObject([{
|
||||||
|
segment: [0, 1],
|
||||||
|
description: "G¹ (Tangent Continuity)",
|
||||||
|
category: "chapter" as Category
|
||||||
|
}, {
|
||||||
|
segment: [1, 8000],
|
||||||
|
description: "G² (Tangent Continuity)",
|
||||||
|
category: "chapter" as Category
|
||||||
|
}]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user