initial commit

This commit is contained in:
Brahim Hadriche committed 2022-10-30 16:17:37 -04:00
commit 0eadc5da55
37 files changed
+1286

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
import "pkg:/source/services/Invidious.bs"
sub Init()
' set the name of the function in the Task node component to be executed when the state field changes to RUN
' in our case this method executed after the following cmd: m.contentTask.control = "run"(see Init method in MainScene)
m.top.functionName = "GetContent"
end sub
sub GetContent()
rootChildren = []
trendingJson = RokuYoutube.Services.Invidious.GetTrending()
trending = GetCategoryContent("Trending", trendingJson)
if trending <> invalid
rootChildren.Push(trending)
end if
popularJson = RokuYoutube.Services.Invidious.GetPopular()
popular = GetCategoryContent("Popular", popularJson)
if popular <> invalid
rootChildren.Push(popular)
end if
' set up a root ContentNode to represent rowList on the GridScreen
contentNode = CreateObject("roSGNode", "ContentNode")
contentNode.Update({
children: rootChildren
}, true)
' populate content field with root content node.
' Observer(see OnMainContentLoaded in MainScene.brs) is invoked at that moment
m.top.content = contentNode
end sub
function GetCategoryContent(category as string, json as object) as object
if json <> invalid
row = {}
row.title = category
row.children = []
for each item in json ' parse items and push them to row
itemData = GetItemData(item)
row.children.Push(itemData)
end for
return row
end if
end function
function GetItemData(video as object) as object
item = {}
item.title = video.title
item.description = video.description
item.hdPosterURL = video.videoThumbnails[0].url
item.releaseDate = video.publishedText
item.id = video.videoId
item.length = video.lengthSeconds
return item
end function
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="MainLoaderTask" extends="Task">
<interface>
<field id="content" type="node" />
</interface>
<script type="text/brightscript" uri="MainLoaderTask.brs" />
</component>
@@ -0,0 +1,33 @@
import "pkg:/source/services/SponsorBlock.bs"
import "pkg:/source/services/Invidious.bs"
sub Init()
' set the name of the function in the Task node component to be executed when the state field changes to RUN
' in our case this method executed after the following cmd: m.contentTask.control = "run"(see Init method in MainScene)
m.top.functionName = "GetVideoContent"
end sub
sub GetVideoContent()
metadata = GetVideoMetadata()
sponsorBlock = GetVideoSponsorBlock()
contentNode = CreateObject("roSGNode", "ContentNode")
content = {}
content["metadata"] = metadata
content["sponsorblock"] = sponsorBlock
contentNode.addFields(content)
m.top.content = contentNode
end sub
function GetVideoMetadata()
videoId = m.top.getField("videoid")
return RokuYoutube.Services.Invidious.GetVideoMetadataForVideo(videoId)
end function
function GetVideoSponsorBlock()
videoId = m.top.getField("videoid")
return RokuYoutube.Services.SponsorBlock.GetSkipSegmentsForVideo(videoId)
end function
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="VideoDetailsLoaderTask" extends="Task">
<interface>
<field id="content" type="node" />
<field id="videoid" type="string" />
</interface>
<script type="text/brightscript" uri="VideoDetailsLoaderTask.brs" />
</component>