Add SponsorBlock Viewed API (#31)

* Add SponsorBlock Viewed API

* Add task for viewed events

* Changelog
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-01-01 13:02:53 -05:00
1 parent 5822207397
commit 493a8f7d17
5 files changed
+35

No files matched your search

@@ -0,0 +1,12 @@
import "pkg:/source/services/SponsorBlock.bs"
function Init()
m.top.functionName = "TaskMain"
end function
function TaskMain()
input = m.top.getField("input")
segmentId = input.segmentId
SponsorBlock.PostSegmentViewed(segmentId)
end function
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="SponsorBlockTrackingTask" extends="Task">
<interface>
<field id="input" type="assocarray" />
<field id="output" type="assocarray" />
</interface>
</component>
@@ -119,6 +119,7 @@ function OnPositionChangeSkipSponsorBlockSections() as void
' TODO: if segmentEnd is at the end of the video, close video
m.top.seek = segmentEnd
print("Skiping section:" + segment["category"])
SendSkippedSectionEvent(segment.UUID)
return
end if
end if
@@ -141,3 +142,9 @@ function OnPositionChangeSkipSponsorBlockSections() as void
m.top.mute = shouldMute
end if
end function
function SendSkippedSectionEvent(segmentId as string)
task = createObject("roSGNode", "SponsorBlockTrackingTask")
task.input = { segmentId: segmentId }
task.control = "RUN"
end function