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,99 @@
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesTask.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
function Init()
m.log = new log.Logger("InvidiousPublicInstances")
m.failedLabel = m.top.findNode("failedLabel")
m.refreshButton = m.top.findNode("refreshButton")
m.instances = m.top.findNode("instances")
m.instancesHeader = m.top.findNode("instancesHeader")
m.busySpinner = m.top.findNode("busySpinner")
m.busyspinner.poster.width = 100
m.busyspinner.poster.height = 100
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
m.instances.ObserveField("itemSelected", FuncName(OnInstanceSelected))
m.refreshButton.ObserveField("buttonSelected", FuncName(Refresh))
Refresh()
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
if m.refreshButton.visible
NodeSetFocus(m.refreshButton, true)
else
NodeSetFocus(m.instances, true)
end if
end function
function Refresh()
m.top.focusable = false
m.instances.visible = false
m.instancesHeader.visible = false
m.failedLabel.visible = false
m.refreshButton.visible = false
if m.invidiousPublicInstancesTask <> invalid
m.invidiousPublicInstancesTask.cancel = true
end if
m.invidiousPublicInstancesTask = StartAsyncTask(InvidiousPublicInstancesTask, {
listNode: m.instances
}, OnInvidiousPublicInstancesTaskResults)
m.busySpinner.visible = true
m.busySpinner.control = "start"
end function
function OnInvidiousPublicInstancesTaskResults(output as object) as void
m.top.focusable = true
m.busySpinner.visible = false
m.busySpinner.control = "stop"
m.invidiousPublicInstancesTask = 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(output.error)
message = `Failed to load Invidious public instances\n${error}`
DialogUtils.ShowDialog(message, "Invidious public instances load error", true)
m.failedLabel.visible = true
m.refreshButton.visible = true
if m.top.IsInFocusChain()
NodeSetFocus(m.top, true)
end if
return
end if
m.instances.visible = true
m.instancesHeader.visible = true
if m.top.IsInFocusChain()
NodeSetFocus(m.top, true)
end if
end function
function OnInstanceSelected(event as object) as void
selected = m.instances.itemSelected
itemContent = m.instances.content.GetChild(selected)
m.top.instance = itemContent.uri
end function
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="InvidiousPublicInstances" extends="Group" includes="Focus">
<interface>
<field id="instance" type="string" />
</interface>
<children>
<BusySpinner
id="busySpinner"
translation="[380,96]" />
<Label
id="failedLabel"
text="Failed to load Invidious public instances."
translation="[190,60]" />
<Button
id="refreshButton"
minWidth="0"
text="Refresh"
translation="[340,130]" />
<InvidiousPublicInstancesListItem id="instancesHeader">
<InvidiousPublicInstancesListItemContent
role="itemContent"
name="name"
version="version"
users="users"
signup="signup"
location="location"
health="health" />
</InvidiousPublicInstancesListItem>
<MarkupGrid
id="instances"
itemComponentName="InvidiousPublicInstancesListItem"
itemSize="[860,16]"
itemSpacing="[0,20]"
numColumns="1"
numRows="7"
vertFocusAnimationStyle="floatingFocus"
translation="[0,46]" />
</children>
</component>
@@ -0,0 +1,22 @@
function Init()
m.nameLabel = m.top.findNode("nameLabel")
m.versionLabel = m.top.findNode("versionLabel")
m.usersLabel = m.top.findNode("usersLabel")
m.signupLabel = m.top.findNode("signupLabel")
m.locationLabel = m.top.findNode("locationLabel")
m.flagEmoji = m.top.findNode("flagEmoji")
m.healthLabel = m.top.findNode("healthLabel")
end function
function OnContentSet() as void
content = m.top.itemContent
m.nameLabel.text = content.name
m.versionLabel.text = content.version
m.usersLabel.text = content.users
m.signupLabel.text = content.signup
m.locationLabel.text = content.location
m.flagEmoji.uri = content.flag
m.healthLabel.text = content.health
end function
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="InvidiousPublicInstancesListItem" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
</interface>
<children>
<Label
id="nameLabel"
font="font:SmallestSystemFont"
width="240" />
<Label
id="versionLabel"
font="font:SmallestSystemFont"
width="220"
translation="[240,0]" />
<Label
id="usersLabel"
font="font:SmallestSystemFont"
width="100"
translation="[460,0]" />
<Label
id="signupLabel"
font="font:SmallestSystemFont"
width="90"
translation="[550,0]" />
<Label
id="locationLabel"
font="font:SmallestSystemFont"
width="100"
translation="[650,0]" />
<Poster
id="flagEmoji"
width="16"
height="16"
translation="[650,0]" />
<Label
id="healthLabel"
font="font:SmallestSystemFont"
width="100"
translation="[750,0]" />
</children>
</component>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="InvidiousPublicInstancesListItemContent" extends="ContentNode">
<interface>
<field id="name" type="string" />
<field id="version" type="string" />
<field id="users" type="string" />
<field id="signup" type="string" />
<field id="location" type="string" />
<field id="flag" type="string" />
<field id="health" type="string" />
<field id="uri" type="string" />
</interface>
</component>
@@ -0,0 +1,79 @@
import "pkg:/source/services/HttpClient.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
@asynctask
function InvidiousPublicInstancesTask(input as object) as object
listNode = input.listNode
if m.top.cancel
return invalid
end if
response = HttpClient.Get(Invidious.INSTANCES_API).Await()
instances = response.Json()
if not response.IsSuccess() or instances = invalid
return {
success: false,
error: response.ErrorMessage()
}
end if
if m.top.cancel
return invalid
end if
instances = FilterInstances(instances)
content = CreateObject("roSGNode", "ContentNode")
for each instance in instances
item = CreateObject("roSGNode", "InvidiousPublicInstancesListItemContent")
item.setFields({
name: instance[0],
version: instance[1].stats.software.version,
users: instance[1].stats.usage.users.total,
signup: instance[1].stats.openRegistrations ? "Yes" : "No",
' Leave 5 spaces for the flag, just to simplify the layout
location: ` ${instance[1].region}`,
flag: GetFlagUrl(instance[1].flag),
health: instance[1].monitor["30dRatio"].ratio,
uri: instance[1].uri
})
content.AppendChild(item)
end for
listNode.content = content
return {
success: true
}
end function
function FilterInstances(instances as object) as object
filtered = []
for each instance in instances
flags = instance[1]
if flags.type = "https" and flags.api = true and flags.cors = true
filtered.Push(instance)
end if
end for
return filtered
end function
function GetFlagUrl(flag as string) as string
codePoint = emojiToCodePoint(flag)
return `https://github.githubassets.com/images/icons/emoji/unicode/${codePoint}.png?v8`
end function
function emojiToCodePoint(emoji as string) as string
codes = []
chars = emoji.Split("")
for i = 0 to chars.count() - 1
c = Asc(chars[i])
codes.push(StrI(c, 16))
end for
return codes.join("-")
end function