Generated task (#34)
* Async stash * tweak * Kinda works * Things work fine * Home grid task test * Convert some promises to regular tasks (#33) * Remove promise * Sponsorblock view task * Complete task cleanups * Prevent parallel search tasks * Comment * Changelog * Rename task, handle cleanups * Support task by name * Small changes
This commit is contained in:
1 parent
9a65bd4657
commit
fc20cfd7b4
27 files changed
+633
-236
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import "pkg:/source/services/SponsorBlock.bs"
|
||||
|
||||
function TaskMain()
|
||||
input = m.top.getField("input")
|
||||
@asynctask
|
||||
function SponsorBlockTask(input as object) as object
|
||||
videoId = input.videoId
|
||||
|
||||
sponsorBlockResponse = SponsorBlock.GetSkipSegmentsForVideo(videoId)
|
||||
@@ -25,9 +25,9 @@ function TaskMain()
|
||||
SponsorBlock.GenerateProgressBarBackground(skipSegments, barPath)
|
||||
end if
|
||||
|
||||
m.top.setField("output", {
|
||||
return {
|
||||
videoId: videoId,
|
||||
skipSegments: skipSegments,
|
||||
barPath: barPath
|
||||
})
|
||||
}
|
||||
end function
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="SponsorBlockTask" extends="Task">
|
||||
<interface>
|
||||
<field id="input" type="assocarray" />
|
||||
<field id="output" type="assocarray" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,10 +1,7 @@
|
||||
import "pkg:/source/services/SponsorBlock.bs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "TaskMain"
|
||||
end function
|
||||
|
||||
function TaskMain()
|
||||
@asynctask
|
||||
function SponsorBlockTrackingTask(input as object)
|
||||
input = m.top.getField("input")
|
||||
segmentId = input.segmentId
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,6 +1,5 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/source/roku_modules/rokupromise/Promise.brs"
|
||||
|
||||
function PlayVideo(videoId as string, sender as object)
|
||||
width = 1280
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "TaskMain"
|
||||
end function
|
||||
|
||||
function TaskMain()
|
||||
input = m.top.getField("input")
|
||||
@asynctask
|
||||
function VideoDetailsTask(input as object) as object
|
||||
videoId = input.videoId
|
||||
|
||||
metadata = Invidious.GetVideoMetadata(videoId)
|
||||
|
||||
m.top.setField("output", {
|
||||
return {
|
||||
videoId: videoId,
|
||||
metadata: metadata
|
||||
})
|
||||
}
|
||||
end function
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="VideoDetailsTask" extends="Task">
|
||||
<interface>
|
||||
<field id="input" type="assocarray" />
|
||||
<field id="output" type="assocarray" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,6 +1,7 @@
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/services/SponsorBlock.bs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
import "pkg:/components/VideoPlayer/VideoDetailsTask.bs"
|
||||
|
||||
function Init()
|
||||
SetupSponsorBlock()
|
||||
@@ -15,8 +16,6 @@ function Init()
|
||||
m.top.enableUI = m.videoContainer.fullscreen
|
||||
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
||||
|
||||
m.videoDetailsTask = m.top.findNode("VideoDetailsTask")
|
||||
|
||||
m.videoPlayingSuccess = false
|
||||
m.ignoreNextFinishedState = false
|
||||
|
||||
@@ -47,21 +46,26 @@ end function
|
||||
|
||||
function OnControlChange()
|
||||
if m.top.control = "stop"
|
||||
m.sponsorBlockTask.control = "stop"
|
||||
m.videoDetailsTask.control = "stop"
|
||||
if m.videoDetailsTask <> invalid
|
||||
m.videoDetailsTask.control = "stop"
|
||||
end if
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.control = "stop"
|
||||
end if
|
||||
end if
|
||||
end function
|
||||
|
||||
function StartVideoDetailsTask()
|
||||
m.videoDetailsTask.input = { videoId: m.top.videoId }
|
||||
m.videoDetailsTask.observeField("output", "OnVideoDetailsTaskResults")
|
||||
m.videoDetailsTask.control = "run"
|
||||
if m.videoDetailsTask <> invalid
|
||||
m.videoDetailsTask.control = "stop"
|
||||
end if
|
||||
|
||||
m.videoDetailsTask = StartAsyncTask(VideoDetailsTask, { videoId: m.top.videoId }, OnVideoDetailsTaskResults)
|
||||
end function
|
||||
|
||||
function OnVideoDetailsTaskResults() as void
|
||||
task = m.videoDetailsTask
|
||||
videoId = task.output.videoId
|
||||
metadata = task.output.metadata
|
||||
function OnVideoDetailsTaskResults(output as object) as void
|
||||
videoId = output.result.videoId
|
||||
metadata = output.result.metadata
|
||||
if videoId <> m.top.videoId
|
||||
return
|
||||
end if
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
<field id="videoId" type="string" />
|
||||
</interface>
|
||||
<children>
|
||||
<SponsorBlockTask
|
||||
functionName="TaskMain"
|
||||
id="SponsorBlockTask" />
|
||||
<VideoDetailsTask
|
||||
functionName="TaskMain"
|
||||
id="VideoDetailsTask" />
|
||||
|
||||
<Label
|
||||
id="chapterLabel"
|
||||
width="350"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTask.bs"
|
||||
import "pkg:/components/VideoPlayer/SponsorBlockTrackingTask.bs"
|
||||
|
||||
function SetupSponsorBlock()
|
||||
PositionChapterLabel()
|
||||
m.timeLabel = FindTimeLabel()
|
||||
m.top.trickPlayBar.observeField("visible", "OnTrickPlayBarVisible")
|
||||
m.chapterLabelTimer = m.top.findNode("chapterLabelTimer")
|
||||
m.chapterLabelTimer.observeField("fire", "OnChapterLabelTimer")
|
||||
m.sponsorBlockTask = m.top.findNode("SponsorBlockTask")
|
||||
m.top.observeField("videoId", "StartSponsorBlockTask")
|
||||
end function
|
||||
|
||||
@@ -79,15 +82,16 @@ function UpdateSponsorBlockChapter(time as integer) as void
|
||||
end function
|
||||
|
||||
function StartSponsorBlockTask()
|
||||
m.sponsorBlockTask.input = { videoId: m.top.videoId }
|
||||
m.sponsorBlockTask.observeField("output", "OnSponsorBlockTaskResults")
|
||||
m.sponsorBlockTask.control = "run"
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.control = "stop"
|
||||
end if
|
||||
|
||||
m.sponsorBlockTask = StartAsyncTask(SponsorBlockTask, { videoId: m.top.videoId }, OnSponsorBlockTaskResults)
|
||||
end function
|
||||
|
||||
function OnSponsorBlockTaskResults()
|
||||
task = m.sponsorBlockTask
|
||||
skipSegments = task.output.skipSegments
|
||||
barPath = task.output.barPath
|
||||
function OnSponsorBlockTaskResults(output as object)
|
||||
skipSegments = output.result.skipSegments
|
||||
barPath = output.result.barPath
|
||||
if skipSegments <> invalid
|
||||
m.skipSegments = skipSegments
|
||||
m.top.seekMode = "accurate"
|
||||
@@ -144,7 +148,5 @@ function OnPositionChangeSkipSponsorBlockSections() as void
|
||||
end function
|
||||
|
||||
function SendSkippedSectionEvent(segmentId as string)
|
||||
task = createObject("roSGNode", "SponsorBlockTrackingTask")
|
||||
task.input = { segmentId: segmentId }
|
||||
task.control = "RUN"
|
||||
StartAsyncTask(SponsorBlockTrackingTask, { segmentId: segmentId })
|
||||
end function
|
||||
Reference in new issue
Block a user