Fix sponsor skip infinite loop bug (#231)
This commit is contained in:
1 parent
54b0acbe8f
commit
f581d568d9
4 files changed
+42
-21
No files matched your search
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- (Regression) Issue where auto-play keeps playing the same videos in a loop
|
||||
- Small search box styling bug for Safari
|
||||
- A bug where the skipping of a sponsored section at the end of a video leads to an infinite loop
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace SponsorBlock
|
||||
|
||||
class SponsorBlockService
|
||||
function new()
|
||||
' TODO:P2 this is being read and parsed on every skipped segment. It should be cached.
|
||||
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
|
||||
end function
|
||||
|
||||
|
||||
@@ -135,10 +135,23 @@ namespace SponsorBlock
|
||||
end if
|
||||
|
||||
if action = "AutoSkip"
|
||||
m.top.seek = segmentEnd
|
||||
LogInfo("Skipping section:", segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
return
|
||||
duration = m.top.duration
|
||||
' Sometimes segmentEnd is greater than duration
|
||||
if duration > 0 and segmentEnd > duration
|
||||
segmentEnd = duration
|
||||
end if
|
||||
' If the segment is at the end of the video, skip the video instead of seeking
|
||||
if duration > 0 and Abs(segmentEnd - duration) < 2
|
||||
LogInfo("Skipping section:", segment["category"], "at end of video")
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
OnVideoFinished()
|
||||
return
|
||||
else
|
||||
LogInfo("Skipping section:", segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
m.top.seek = segmentEnd
|
||||
return
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
@@ -185,23 +185,8 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
|
||||
if state = "finished"
|
||||
if content = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
metadata = content.metadata
|
||||
if metadata = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
if not PlayNext(metadata.recommendedVideos)
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
end if
|
||||
OnVideoFinished()
|
||||
return
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
@@ -225,6 +210,27 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVideoFinished() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
metadata = content.metadata
|
||||
if metadata = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
if not PlayNext(metadata.recommendedVideos)
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
end if
|
||||
end function
|
||||
|
||||
function PlayNext(recommendedVideos as object) as boolean
|
||||
if m.playQueue@.PlayNextItem()
|
||||
return true
|
||||
|
||||
Reference in new issue
Block a user