Fix for sponsorblock highlight label

This commit is contained in:
Brahim Hadriche committed 2024-02-26 09:46:20 -05:00
1 parent ef9c653ad7
commit b25eaafc82
2 files changed
+28 -1

No files matched your search

+1
View File
@@ -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
@@ -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