Compare commits

...

5 Commits

Author SHA1 Message Date
Ajay
f764869cc8 Add another test case 2022-12-19 16:19:01 -05:00
Ajay
2ba5fa6954 bump version 2022-12-19 16:14:41 -05:00
Ajay
35b8a34162 Don't remove trailing end bracket when not starting with bracket 2022-12-19 16:12:51 -05:00
Ajay Ramachandran
3379189ea8 remove serious part of warning message 2022-12-19 13:13:38 -05:00
Ajay Ramachandran
e6be13b583 make warning message nicer 2022-12-19 13:11:03 -05:00
4 changed files with 36 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "__MSG_fullName__", "name": "__MSG_fullName__",
"short_name": "SponsorBlock", "short_name": "SponsorBlock",
"version": "5.1.9", "version": "5.1.10",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_Description__", "description": "__MSG_Description__",
"homepage_url": "https://sponsor.ajay.app", "homepage_url": "https://sponsor.ajay.app",

View File

@@ -942,7 +942,7 @@
"message": "Hide forever" "message": "Hide forever"
}, },
"warningChatInfo": { "warningChatInfo": {
"message": "We noticed you were making some common mistakes that are not malicious" "message": "We noticed you were making some common mistakes. We very much appreciate your work so far, but we strive towards perfection here, so even very small mistakes matter :)"
}, },
"warningTitle": { "warningTitle": {
"message": "You got a warning" "message": "You got a warning"

View File

@@ -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]);

View File

@@ -275,4 +275,36 @@ 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
}]);
});
it ("((Some name) 1:20)", () => {
const input = ` ((Some name) 1:20)
((Some other name) 1:25)`;
const result = importTimes(input, 8000);
expect(result).toMatchObject([{
segment: [80, 85],
description: "Some name",
category: "chapter" as Category
}, {
segment: [85, 8000],
description: "Some other name",
category: "chapter" as Category
}]);
});
}); });