Fresh start (#110)

* Fresh start

* Create an xml include plugin (#111)

* Restructure and add testing (#114)

* rooibos setup

* Restructure and add testing

* docs

* Restore manifestpipi

* Description in tools

* A bit of docs

* Auto bind feature (#115)

* Auto bind feature

* Fix children merge

* bs plugin fix

* Feature/app controller (#120)

* Initial layout

* Restructuring and plugin work

* A couple of tweaks in binding stuff

* tweaks

* basic stack

* Add basic app controller

* Support json5/yaml in playlet config files (#123)

* Support json5 in playlet config files

* Add yaml to the mix

* Delete old lib project

* plugin fix

* plugin tweak

* verbose logging

* Revert "verbose logging"

This reverts commit 25867f4226703d83102519a0d48d1cc46a9876de.

* One idea to fix the include plugin

* Fix instability in plugins

* Feature/navbar (#126)

* Navbar

* typo

* comment

* Single content node, and tests

* Remove unused field

* tweaks

* update dependencies command

* tweak formatting

* Add web app screen

* Set id in created screens

* Search screen

* Tests

* Show playlists and channels in search results

* Move screen stuff to app controller

* Home screen (wip)

* Add preferences node

* README.md copyedits (#130)

* README.md: Fix typos

* README.md: Standardize capitalization and punctuation

* Update docs/README.md

---------

Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>

* Web server: round 1 (#131)

* web server object

* Logging

* Web server round 1

* Lint fix

* Small tweaks

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>

* Logging to file

* Leftover

* Add logs file to web server

* Fix for timeout

* Disable keepalive connection

* add openapi spec file

* Lint fix

* add prefs version in api

* Add ecp api definition

* Lint fix

* Settings rework (#135)

* Settings rework

* Standard OnFocusChange event

* Video player stuff (#136)

* Video player stuff

* Restructure things so that focus is better handled

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>

* Exit dialog

* A bunch of changes

* New http client

* Set TODO priorities

* picture in picture

* mark video watched

* Video player stuff mostly there

* update spec file

* Sponsorblock

* FuncName

* SponsorBlock notifications

* Lint fix

* misc

* remove basic auth feature flag (until we start using it)

* Play queue part 1

* type fix

* handle unicode in request body

* SponsorBlock chapter label

* modal base

* remove a hack

* Invidious settings

* web server reduce timeout

* Test for captions

* Lint fix

* remove rpc stuff

* small change

* Solve focus management

* a couple of fixes

* Remove a bunch of todos

* feed error handling wip

* Lint fix

* navigation in instance settings

* home screen pagination support

* Refactor feed to support pagination on search page

* cell loading animation

* Tweak caching

* delete test screen

* playlist support part 1

* Basic playlist view

* Restore playlist/channel handler

* Refactor some content node stuff, and add an auth popup dialog

* A bad implementation of a playqueue

* Lint fix

* playlist cast fix

* Feature/web app catch up (#139)

* playlist cast fix

* Move things around

* support playlists in web app

* update api

* Bump deps

* Downgrade todo

---------

Co-authored-by: Bryce Harrington <bryce@bryceharrington.org>
Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
authored and GitHub committed 2023-09-07 17:18:25 -04:00
1 parent 79f74141c5
commit 43166fb43b
349 files changed
+12784 -7660

No files matched your search

@@ -0,0 +1,48 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
' TODO:P1 this should only be called from PlaylistContentNode.bs
@asynctask
function PlaylistContentTask(input as object) as object
contentNode = input.content
invidiousNode = input.invidious
if m.top.cancel
contentNode.loadState = FeedLoadState.None
return invalid
end if
service = new Invidious.InvidiousService(invidiousNode)
index = contentNode.getChildCount()
response = service.GetPlaylist(contentNode.playlistId, index, m.top.cancellation)
if m.top.cancel
contentNode.loadState = FeedLoadState.None
return invalid
end if
metadata = response.Json()
if not response.IsSuccess() or metadata = invalid
contentNode.loadState = FeedLoadState.Error
return {
success: false,
error: response.ErrorMessage()
}
end if
instance = service.GetInstance()
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
childCount = contentNode.getChildCount()
if metadata.videos.Count() > 0 or childCount < metadata.videoCount
contentNode.loadState = FeedLoadState.LoadedPage
else
contentNode.loadState = FeedLoadState.Loaded
end if
return {
success: true
}
end function
@@ -0,0 +1,8 @@
namespace PlaylistUtils
function Open(contentNode as object)
playlistView = CreateObject("roSGNode", "PlaylistView")
m.appController@.PushScreen(playlistView)
playlistView@.BindNode(invalid)
playlistView.content = contentNode
end function
end namespace
@@ -0,0 +1,155 @@
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/components/VideoPlayer/VideoUtils.bs"
import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/PlaylistView/PlaylistContentTask.bs"
import "pkg:/components/VideoFeed/FeedLoadState.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
' TODO:P2 use already loaded thumbnail, and crossfade to highres version (using same Poster)
function Init()
m.log = new log.Logger("PlaylistView")
m.background = m.top.findNode("background")
m.backgroundSmall = m.top.findNode("backgroundSmall")
m.titleLabel = m.top.findNode("titleLabel")
m.subtitleLabel = m.top.findNode("subtitleLabel")
m.descriptionLabel = m.top.findNode("descriptionLabel")
m.list = m.top.findNode("list")
end function
function OnNodeReady()
m.list.ObserveField("itemFocused", FuncName(OnItemFocused))
m.list.observeField("itemSelected", FuncName(OnItemSelected))
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.list, true)
end function
function OnContentSet() as void
content = m.top.content
if content = invalid
return
end if
m.titleLabel.text = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.subtitleLabel.text = `${content._author} • ${content.videoCountText} • ${content.viewCountText}`
m.descriptionLabel.text = content.description
' TODO:P2 cross fade
m.backgroundSmall.uri = content.thumbnail
m.background.uri = content.thumbnailBackground
itemFocused = m.list.itemFocused
m.list.content = content
if itemFocused > -1 and content.getChildCount() > itemFocused
m.list.jumpToItem = itemFocused
end if
LoadPlaylistIfNeeded()
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if press = false
return false
end if
if key = "back"
Close()
return true
end if
return false
end function
function Close()
if m.playlistLoadTask <> invalid
m.playlistLoadTask.cancel = true
end if
m.appController@.PopScreen(invalid)
end function
function OnItemFocused()
LoadPlaylistIfNeeded()
end function
function OnItemSelected(event as object)
index = event.getData()
playlist = m.list.content
playlistId = playlist.playlistId
video = playlist.getChild(index)
videoId = video.videoId
if not StringUtils.IsNullOrEmpty(videoId)
m.log.info("Play playlist: " + playlistId + " video: " + videoId)
m.playQueue@.Play(playlist, index)
end if
end function
function LoadPlaylistIfNeeded() as void
content = m.top.content
if content = invalid
return
end if
if not content.loadState = FeedLoadState.LoadedPage and not content.loadState = FeedLoadState.None
return
end if
videoCount = content.videoCount
currentVideosCount = content.getChildCount()
if videoCount = currentVideosCount
return
end if
itemFocused = m.list.itemFocused
if itemFocused < currentVideosCount - 5
return
end if
LoadPlaylist()
end function
function LoadPlaylist() as void
if m.playlistLoadTask <> invalid
m.playlistLoadTask.cancel = true
end if
m.top.content.loadState = FeedLoadState.Loading
m.playlistLoadTask = StartAsyncTask(PlaylistContentTask, {
content: m.top.content,
invidious: m.top.invidious
}, OnPlaylistContentTaskResult)
end function
function OnPlaylistContentTaskResult(output as object) as void
m.playlistLoadTask = invalid
if output.cancelled
return
end if
if not output.success or not output.result.success
' output.error for unhandled exception
error = output.error
if error = invalid
' output.result.error for network errors
error = output.result.error
end if
error = ErrorUtils.Format(error)
m.log.error(error)
playlistId = output.task.input.content.playlistId
message = `Failed to load playlist ${playlistId}\n${error}`
DialogUtils.ShowDialog(message, "Playlist load fail", true)
return
end if
LoadPlaylistIfNeeded()
end function
@@ -0,0 +1,58 @@
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="playQueue" type="node" bind="/PlayQueue" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="0x242424">
</Rectangle>
<Poster
id="backgroundSmall"
width="1280"
height="720"
blendColor="0x323232" />
<Poster
id="background"
width="1280"
height="720"
blendColor="0x323232">
<LayoutGroup
itemSpacings="[5,20]"
translation="[65,90]">
<Label
id="titleLabel"
width="500"
maxLines="2"
wrap="true">
<Font role="font" uri="font:BoldSystemFontFile" size="36" />
</Label>
<Label
id="subtitleLabel"
width="500"
font="font:SmallestBoldSystemFont" />
<Label
id="descriptionLabel"
width="500"
maxLines="10"
wrap="true"
font="font:SmallestSystemFont" />
</LayoutGroup>
<MarkupGrid
id="list"
itemComponentName="PlaylistViewCell"
itemSize="[550,106]"
itemSpacing="[0,20]"
numColumns="1"
numRows="5"
vertFocusAnimationStyle="floatingFocus"
translation="[620,90]" />
</Poster>
</children>
</component>
@@ -0,0 +1,44 @@
import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/TimeUtils.bs"
function Init()
m.titleLabel = m.top.findNode("titleLabel")
m.authorLabel = m.top.findNode("authorLabel")
m.thumbnail = m.top.findNode("thumbnail")
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
m.thumbnail.uri = content.thumbnail
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.durationRect.visible = true
else
m.durationRect.visible = false
end if
end function
function SetDurationText(text as string)
label = m.durationLabel
rect = m.durationRect
rectParent = rect.getParent()
label.text = text
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, 72]
end function
@@ -0,0 +1,46 @@
<component name="PlaylistViewCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
</interface>
<children>
<Poster
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="190"
height="106">
<Rectangle
id="durationRect"
width="60"
height="26"
color="0x000000"
opacity="0.8"
translation="[130, 72]">
<Label
height="26"
id="durationLabel"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
translation="[8, 0]" />
</Rectangle>
</Poster>
<LayoutGroup
itemSpacings="[5,5]"
translation="[200,0]">
<Label
id="titleLabel"
width="350"
font="font:SmallestBoldSystemFont"
maxLines="2"
wrap="true" />
<Label
id="authorLabel"
width="350"
height="25"
font="font:SmallestSystemFont" />
</LayoutGroup>
</children>
</component>