From b25eaafc826b31d2c121d771a28a159c55d28a99 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 26 Feb 2024 09:46:20 -0500 Subject: [PATCH] Fix for sponsorblock highlight label --- CHANGELOG.md | 1 + .../components/VideoPlayer/SponsorBlock.bs | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3d2df4..10de85a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `Device connected` notification only show once every 30 minutes per device to avoid spam +- SponsorBlock category "highlight" was not visible in chapter label ## [0.20.1] - 2024-02-23 diff --git a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs index 38ad7e62..792c15b9 100644 --- a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs +++ b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs @@ -63,12 +63,38 @@ namespace SponsorBlock function UpdateSponsorBlockChapter(time as double) as void segments = m.skipSegments for each segment in segments + category = segment["category"] segmentRange = segment["segment"] segmentStart = segmentRange[0] segmentEnd = segmentRange[1] + ' Usually segmentStart and segmentEnd are equal for poi_highlight + ' We pad the duration for poi_highlight segments so that the chapter label + ' can be visible when seeking in trickplay + if category = "poi_highlight" + segmentPaddedDuration = 5 + + duration = m.top.duration + if duration > 0 + if duration < 120 + segmentPaddedDuration = 1 + else if duration < 300 + segmentPaddedDuration = 2 + else if duration < 900 + segmentPaddedDuration = 5 + else + segmentPaddedDuration = 10 + end if + end if + + segmentDuration = Abs(segmentEnd - segmentStart) + padding = Abs(segmentPaddedDuration - segmentDuration) / 2 + segmentStart = segmentStart - padding + segmentEnd = segmentEnd + padding + end if + if (segmentStart <= time) and (segmentEnd >= time) - m.top.chapter = m.sponsorBlockService.SegmentTitle(segment["category"]) + m.top.chapter = m.sponsorBlockService.SegmentTitle(category) return end if end for