aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-04-26 16:44:20 -0400
committerAjay <[email protected]>2024-04-26 16:44:20 -0400
commit56bb22d03d63ca6ae02aacb60562082dd82167ec (patch)
treebb98a7f738407b0b0108e03fa14bbbb4860cef21 /src/utils
parente1d656f43f8b3cfb40e1c521e4103d61db756872 (diff)
downloadSponsorBlock-56bb22d03d63ca6ae02aacb60562082dd82167ec.tar.gz
SponsorBlock-56bb22d03d63ca6ae02aacb60562082dd82167ec.zip
Allow importing segments with no category
Also fixes case when importing chapters when having no permission to submit chapters
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/exporter.ts33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts
index 40d0f257..85e1b383 100644
--- a/src/utils/exporter.ts
+++ b/src/utils/exporter.ts
@@ -53,24 +53,23 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
titleRight = removeIf(split2[split2.length - 1], specialCharMatchers)
const title = titleLeft?.length > titleRight?.length ? titleLeft : titleRight;
- if (title) {
- const determinedCategory = chapterNames.find(c => c.names.includes(title))?.code as Category;
-
- const segment: SponsorTime = {
- segment: [startTime, getFormattedTimeToSeconds(match[1])],
- category: determinedCategory ?? ("chapter" as Category),
- actionType: determinedCategory ? ActionType.Skip : ActionType.Chapter,
- description: title,
- source: SponsorSourceType.Local,
- UUID: generateUserID() as SegmentUUID
- };
-
- if (result.length > 0 && result[result.length - 1].segment[1] === null) {
- result[result.length - 1].segment[1] = segment.segment[0];
- }
-
- result.push(segment);
+ const determinedCategory = chapterNames.find(c => c.names.includes(title))?.code as Category;
+
+ const category = title ? (determinedCategory ?? ("chapter" as Category)) : "chooseACategory" as Category;
+ const segment: SponsorTime = {
+ segment: [startTime, getFormattedTimeToSeconds(match[1])],
+ category,
+ actionType: category === "chapter" ? ActionType.Chapter : ActionType.Skip,
+ description: category === "chapter" ? title : null,
+ source: SponsorSourceType.Local,
+ UUID: generateUserID() as SegmentUUID
+ };
+
+ if (result.length > 0 && result[result.length - 1].segment[1] === null) {
+ result[result.length - 1].segment[1] = segment.segment[0];
}
+
+ result.push(segment);
}
}
}