From 9ad636fdadc5709d7205e81d12ae80334ed08a3a Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 8 Dec 2024 14:50:40 -0500 Subject: Make chapter similarity check more strict --- src/js-components/previewBar.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 5dc5fefe..84c1e2fd 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -235,9 +235,12 @@ class PreviewBar { // Remove unnecessary original chapters if submitted replacements exist for (const chapter of this.segments.filter((s) => s.actionType === ActionType.Chapter && s.source === SponsorSourceType.Server)) { + const segmentDuration = chapter.segment[1] - chapter.segment[0]; + const duplicate = this.segments.find((s) => s.actionType === ActionType.Chapter && s.source === SponsorSourceType.YouTube - && Math.abs(s.segment[0] - chapter.segment[0]) < 3 && Math.abs(s.segment[1] - chapter.segment[1]) < 3); + && Math.abs(s.segment[0] - chapter.segment[0]) < Math.min(3, segmentDuration / 3) + && Math.abs(s.segment[1] - chapter.segment[1]) < Math.min(3, segmentDuration / 3)); if (duplicate) { const index = this.segments.indexOf(duplicate); -- cgit v1.2.3