Fix sponsor skip infinite loop bug (#231)
This commit is contained in:
1 parent
54b0acbe8f
commit
f581d568d9
4 files changed
+38
-17
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
|
- (Regression) Issue where auto-play keeps playing the same videos in a loop
|
||||||
- Small search box styling bug for Safari
|
- 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
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace SponsorBlock
|
|||||||
|
|
||||||
class SponsorBlockService
|
class SponsorBlockService
|
||||||
function new()
|
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"))
|
m.sponsorBlockConfig = ParseJson(ReadAsciiFile("libpkg:/config/sponsorblock_config.json5"))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -135,12 +135,25 @@ namespace SponsorBlock
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if action = "AutoSkip"
|
if action = "AutoSkip"
|
||||||
m.top.seek = segmentEnd
|
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"])
|
LogInfo("Skipping section:", segment["category"])
|
||||||
SendSkippedSectionEvent(segment.UUID)
|
SendSkippedSectionEvent(segment.UUID)
|
||||||
|
m.top.seek = segmentEnd
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
end for
|
end for
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -185,25 +185,10 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if state = "finished"
|
if state = "finished"
|
||||||
if content = invalid
|
OnVideoFinished()
|
||||||
m.playQueue@.watchedVideosClear()
|
|
||||||
VideoUtils.CloseVideo()
|
|
||||||
return
|
return
|
||||||
end if
|
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 if
|
|
||||||
|
|
||||||
if state = "error"
|
if state = "error"
|
||||||
messageLines = []
|
messageLines = []
|
||||||
messageLines.push(`errorMsg: ${m.top.errorMsg}`)
|
messageLines.push(`errorMsg: ${m.top.errorMsg}`)
|
||||||
@@ -225,6 +210,27 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end if
|
end if
|
||||||
end function
|
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
|
function PlayNext(recommendedVideos as object) as boolean
|
||||||
if m.playQueue@.PlayNextItem()
|
if m.playQueue@.PlayNextItem()
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in new issue
Block a user