SponsorBlock categories (#70)
* SponsorBlock categories * Remove faulty animation check * Changelog
This commit is contained in:
1 parent
b7e6a1ea83
commit
9a631aab51
5 files changed
+37
-43
No files matched your search
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
### Changed
|
||||||
|
- SponsorBlock segments are not skipped by default, except for sponsor segments
|
||||||
|
|
||||||
## [0.9.0] - 2023-04-21
|
## [0.9.0] - 2023-04-21
|
||||||
### Added
|
### Added
|
||||||
- Add watched videos to Invidious watch history
|
- Add watched videos to Invidious watch history
|
||||||
|
|||||||
@@ -11,10 +11,16 @@ function Init()
|
|||||||
m.animationTimer.observeField("fire", "OnAnimationTimer")
|
m.animationTimer.observeField("fire", "OnAnimationTimer")
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnSegmentSet()
|
function OnActionSet()
|
||||||
|
action = m.top.action
|
||||||
category = m.top.segment.category
|
category = m.top.segment.category
|
||||||
categoryTitle = SponsorBlock.SegmentShortTitle(category)
|
categoryTitle = SponsorBlock.SegmentShortTitle(category)
|
||||||
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
|
if action = "AutoSkip"
|
||||||
|
m.categoryLabel.text = "Skipped" + chr(10) + categoryTitle
|
||||||
|
else
|
||||||
|
m.categoryLabel.text = categoryTitle
|
||||||
|
end if
|
||||||
|
|
||||||
AnimateIn()
|
AnimateIn()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -37,23 +43,10 @@ end function
|
|||||||
|
|
||||||
function Animate(reverse as boolean) as void
|
function Animate(reverse as boolean) as void
|
||||||
' We are already animating in the requested direction
|
' We are already animating in the requested direction
|
||||||
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.state = "running"
|
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none"
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
' Check if we are already at the destination
|
|
||||||
if m.translationAnimation.state = "stopped"
|
|
||||||
if reverse
|
|
||||||
destination = m.translationAnimationInterpolator.keyValue[0][0]
|
|
||||||
else
|
|
||||||
destination = m.translationAnimationInterpolator.keyValue[1][0]
|
|
||||||
end if
|
|
||||||
current = m.top.translation[0]
|
|
||||||
if current = destination
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.translationAnimationInterpolator.reverse = reverse
|
m.translationAnimationInterpolator.reverse = reverse
|
||||||
m.translationAnimation.control = "start"
|
m.translationAnimation.control = "start"
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<component name="SponsorBlockNotification" extends="Group">
|
<component name="SponsorBlockNotification" extends="Group">
|
||||||
<interface>
|
<interface>
|
||||||
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
|
<field id="segment" type="assocarray" onChange="OnSegmentSet" />
|
||||||
|
<field id="action" type="string" onChange="OnActionSet" alwaysNotify="true"/>
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
<Rectangle
|
<Rectangle
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
import "pkg:/components/VideoPlayer/Video.bs"
|
import "pkg:/components/VideoPlayer/Video.bs"
|
||||||
|
|
||||||
function ShowSponsorBlockNotifcation(segment as object)
|
function ShowSponsorBlockNotifcation(segment as object, action as dynamic) as void
|
||||||
videoContainer = GetVideoContainer()
|
videoContainer = GetVideoContainer()
|
||||||
notification = videoContainer.findNode("sponsorBlockNotification")
|
notification = videoContainer.findNode("sponsorBlockNotification")
|
||||||
if notification = invalid
|
if notification = invalid
|
||||||
@@ -8,6 +8,7 @@ function ShowSponsorBlockNotifcation(segment as object)
|
|||||||
notification.id = "sponsorBlockNotification"
|
notification.id = "sponsorBlockNotification"
|
||||||
end if
|
end if
|
||||||
notification.segment = segment
|
notification.segment = segment
|
||||||
|
notification.action = action
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function RemoveSponsorBlockNotifcation()
|
function RemoveSponsorBlockNotifcation()
|
||||||
|
|||||||
@@ -109,47 +109,42 @@ function OnSponsorBlockTaskResults(output as object)
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function OnPositionChangeSkipSponsorBlockSections() as void
|
function OnPositionChangeSkipSponsorBlockSections() as void
|
||||||
shouldMute = false
|
|
||||||
muteCategory = ""
|
|
||||||
segments = m.skipSegments
|
segments = m.skipSegments
|
||||||
if segments = invalid
|
if segments = invalid
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
for each segment in segments
|
for each segment in segments
|
||||||
' TODO: handle other action types
|
segmentRange = segment["segment"]
|
||||||
if segment["actionType"] = "skip"
|
segmentStart = segmentRange[0]
|
||||||
segmentRange = segment["segment"]
|
segmentEnd = segmentRange[1]
|
||||||
segmentStart = segmentRange[0]
|
currentPosition = m.top.position
|
||||||
segmentEnd = segmentRange[1]
|
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
||||||
currentPosition = m.top.position
|
action = GetActionForSegment(segment)
|
||||||
if (segmentStart < currentPosition) and ((segmentEnd - 1) > currentPosition)
|
ShowSponsorBlockNotifcation(segment, action)
|
||||||
' TODO: if segmentEnd is at the end of the video, close video
|
|
||||||
|
if action = "AutoSkip"
|
||||||
m.top.seek = segmentEnd
|
m.top.seek = segmentEnd
|
||||||
print("Skipping section:" + segment["category"])
|
print("Skipping section:" + segment["category"])
|
||||||
ShowSponsorBlockNotifcation(segment)
|
|
||||||
SendSkippedSectionEvent(segment.UUID)
|
SendSkippedSectionEvent(segment.UUID)
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if segment["actionType"] = "mute"
|
|
||||||
segmentRange = segment["segment"]
|
|
||||||
segmentStart = segmentRange[0]
|
|
||||||
segmentEnd = segmentRange[1]
|
|
||||||
currentPosition = m.top.position
|
|
||||||
if (segmentStart < currentPosition) and (segmentEnd > currentPosition)
|
|
||||||
shouldMute = true
|
|
||||||
muteCategory = segment["category"]
|
|
||||||
exit for
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
end for
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
if m.top.mute <> shouldMute
|
function GetActionForSegment(segment as object) as dynamic
|
||||||
print(`Muting section: ${muteCategory} - ${shouldMute}`)
|
category = segment["category"]
|
||||||
m.top.mute = shouldMute
|
if category = "sponsor"
|
||||||
|
return "AutoSkip"
|
||||||
|
else if category = "poi_highlight"
|
||||||
|
return "ManualSkip"
|
||||||
|
else if category = "exclusive_access"
|
||||||
|
return "ShowOverlay"
|
||||||
|
else if category = "chapter"
|
||||||
|
return "ShowOverlay"
|
||||||
end if
|
end if
|
||||||
|
return ""
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SendSkippedSectionEvent(segmentId as string)
|
function SendSkippedSectionEvent(segmentId as string)
|
||||||
|
|||||||
Reference in new issue
Block a user