34 lines
856 B
Plaintext
34 lines
856 B
Plaintext
import "pkg:/source/services/SponsorBlock.bs"
|
|
|
|
function TaskMain()
|
|
input = m.top.getField("input")
|
|
videoId = input.videoId
|
|
|
|
sponsorBlockResponse = SponsorBlock.GetSkipSegmentsForVideo(videoId)
|
|
barPath = invalid
|
|
|
|
skipSegments = []
|
|
if sponsorBlockResponse <> invalid
|
|
for each segment in sponsorBlockResponse
|
|
if segment.videoDuration > 0
|
|
skipSegments.push(segment)
|
|
end if
|
|
end for
|
|
end if
|
|
|
|
if skipSegments.Count() = 0
|
|
skipSegments = invalid
|
|
end if
|
|
|
|
if skipSegments <> invalid
|
|
barPath = `tmp:/sponsorblock_bar_${videoId}.png`
|
|
SponsorBlock.GenerateProgressBarBackground(skipSegments, barPath)
|
|
end if
|
|
|
|
m.top.setField("output", {
|
|
videoId: videoId,
|
|
skipSegments: skipSegments,
|
|
barPath: barPath
|
|
})
|
|
end function
|