diff --git a/CHANGELOG.md b/CHANGELOG.md index 3feecb0b..dd0a3a8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed - Bug where app freezes if metadata fails to fetch +- A bug where SponsorBlock returning videoDuration of zero causes the app to hang ## [0.5.0] - 2022-12-02 ### Added diff --git a/src/components/VideoPlayer/SponsorBlockTask.bs b/src/components/VideoPlayer/SponsorBlockTask.bs index 8561e998..d0f403b2 100644 --- a/src/components/VideoPlayer/SponsorBlockTask.bs +++ b/src/components/VideoPlayer/SponsorBlockTask.bs @@ -4,9 +4,20 @@ function TaskMain() input = m.top.getField("input") videoId = input.videoId - skipSegments = SponsorBlock.GetSkipSegmentsForVideo(videoId) + sponsorBlockResponse = SponsorBlock.GetSkipSegmentsForVideo(videoId) barPath = invalid + skipSegments = [] + for each segment in sponsorBlockResponse + if segment.videoDuration > 0 + skipSegments.push(segment) + end if + end for + + if skipSegments.Count() = 0 + skipSegments = invalid + end if + if skipSegments <> invalid barPath = `tmp:/sponsorblock_bar_${videoId}.png` SponsorBlock.GenerateProgressBarBackground(skipSegments, barPath)