Add SponsorBlock Viewed API (#31)
* Add SponsorBlock Viewed API * Add task for viewed events * Changelog
This commit is contained in:
1 parent
5822207397
commit
493a8f7d17
5 files changed
+35
No files matched your search
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
- Ability to clear search history from web app
|
- Ability to clear search history from web app
|
||||||
- WebSocket server for realtime events
|
- WebSocket server for realtime events
|
||||||
|
- SponsorBlock tracking
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- The License has changed from MIT to AGPL
|
- The License has changed from MIT to AGPL
|
||||||
|
|||||||
@@ -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
|
' TODO: if segmentEnd is at the end of the video, close video
|
||||||
m.top.seek = segmentEnd
|
m.top.seek = segmentEnd
|
||||||
print("Skiping section:" + segment["category"])
|
print("Skiping section:" + segment["category"])
|
||||||
|
SendSkippedSectionEvent(segment.UUID)
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
@@ -141,3 +142,9 @@ function OnPositionChangeSkipSponsorBlockSections() as void
|
|||||||
m.top.mute = shouldMute
|
m.top.mute = shouldMute
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function SendSkippedSectionEvent(segmentId as string)
|
||||||
|
task = createObject("roSGNode", "SponsorBlockTrackingTask")
|
||||||
|
task.input = { segmentId: segmentId }
|
||||||
|
task.control = "RUN"
|
||||||
|
end function
|
||||||
@@ -5,6 +5,7 @@ import "pkg:/source/utils/Crypto.bs"
|
|||||||
namespace SponsorBlock
|
namespace SponsorBlock
|
||||||
const API_URL = "https://sponsor.ajay.app"
|
const API_URL = "https://sponsor.ajay.app"
|
||||||
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
const SKIP_SEGMENT_ENDPOINT = "/api/skipSegments"
|
||||||
|
const VIEWED_SEGMENT_ENDPOINT = "/api/viewedVideoSponsorTime"
|
||||||
|
|
||||||
function SegmentColor(category as string) as integer
|
function SegmentColor(category as string) as integer
|
||||||
map = m.SponsorBlockColors
|
map = m.SponsorBlockColors
|
||||||
@@ -75,6 +76,12 @@ namespace SponsorBlock
|
|||||||
return invalid
|
return invalid
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function PostSegmentViewed(segmentId as string) as boolean
|
||||||
|
url = `${SponsorBlock.API_URL}${SponsorBlock.VIEWED_SEGMENT_ENDPOINT}?UUID=${segmentId}`
|
||||||
|
response = Requests().post(url)
|
||||||
|
return response.statuscode = 200
|
||||||
|
end function
|
||||||
|
|
||||||
function GenerateProgressBarBackground(segments as object, path as string)
|
function GenerateProgressBarBackground(segments as object, path as string)
|
||||||
bar = CreateObject("roBitmap", { width: 1000, height: 20, AlphaEnable: true })
|
bar = CreateObject("roBitmap", { width: 1000, height: 20, AlphaEnable: true })
|
||||||
bar.Clear(&hFFFFFF80)
|
bar.Clear(&hFFFFFF80)
|
||||||
|
|||||||
Reference in new issue
Block a user