diff options
author | Ajay <[email protected]> | 2024-12-08 14:50:40 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2024-12-08 14:50:40 -0500 |
commit | 9ad636fdadc5709d7205e81d12ae80334ed08a3a (patch) | |
tree | 510fd2d5ecd079f2ece620ae9270c7fb5dede027 | |
parent | 6bfc66740e50f2597dcef25365ebf68c255e5e43 (diff) | |
download | SponsorBlock-9ad636fdadc5709d7205e81d12ae80334ed08a3a.tar.gz SponsorBlock-9ad636fdadc5709d7205e81d12ae80334ed08a3a.zip |
Make chapter similarity check more strict
-rw-r--r-- | src/js-components/previewBar.ts | 5 |
1 files changed, 4 insertions, 1 deletions
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); |