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,75 @@
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
import "pkg:/source/asyncTask/asyncTask.bs"
import "pkg:/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
function Init()
m.titleLabel = m.top.findNode("titleLabel")
m.closeButton = m.top.findNode("closeButton")
m.testList = m.top.findNode("testList")
m.closeButton.observeField("buttonSelected", FuncName(Close))
m.testList.observeField("itemSelected", FuncName(ShowTestDetails))
SetNavigation(m.closeButton, "up", m.testList)
SetNavigation(m.testList, "down", m.closeButton)
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.closeButton, true)
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled
return true
end if
if key = "options" and press
' A pass-through to the app controller, so it can toggle picture-in-picture
return false
end if
if key = "back" and press
Close()
return true
end if
return true
end function
function Close()
if m.testingTask <> invalid
m.testingTask.cancel = true
end if
m.appController@.PopScreen(invalid)
end function
function RunTestsTask()
m.titleLabel.text = `Testing ${m.top.instance}`
if m.testingTask <> invalid
m.testingTask.cancel = true
end if
m.testingTask = StartAsyncTask(InvidiousInstanceTestingTask, {
instance: m.top.instance,
listNode: m.testList
})
end function
function ShowTestDetails(event as object) as void
selected = m.testList.itemSelected
itemContent = m.testList.content.GetChild(selected)
if StringUtils.IsNullOrEmpty(itemContent.details)
return
end if
message = `Status: ${itemContent.state}\nTest duration: ${itemContent.duration}ms\nDetails: ${itemContent.details}`
DialogUtils.ShowDialog(message, `Test: ${itemContent.title}`)
end function
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="InvidiousInstanceTesting" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="instance" type="string" />
<field id="run" type="boolean" alwaysNotify="true" onChange="RunTestsTask" />
<field id="appController" type="node" bind="/AppController" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
</Rectangle>
<Rectangle
width="960"
height="600"
translation="[160,60]"
color="#242424">
<Label
id="titleLabel"
width="960"
horizAlign="center"
text=""
translation="[0,20]" />
<MarkupGrid
id="testList"
itemSize="[860,40]"
itemSpacing="[0,20]"
numColumns="1"
numRows="7"
vertFocusAnimationStyle="floatingFocus"
translation="[50,80]"
itemComponentName="InvidiousInstanceTestingItem" />
<Button
id="closeButton"
text="Close"
minWidth="0"
showFocusFootprint="true"
translation="[404,506]" />
</Rectangle>
</children>
</component>
@@ -0,0 +1,48 @@
import "pkg:/source/utils/StringUtils.bs"
function Init()
m.busySpinner = m.top.findNode("busySpinner")
m.busyspinner.poster.width = 40
m.busyspinner.poster.height = 40
m.nameLabel = m.top.findNode("nameLabel")
m.detailsLabel = m.top.findNode("detailsLabel")
end function
function OnContentSet() as void
content = m.top.itemContent
m.nameLabel.text = content.title
m.top.state = content.state
end function
function OnStateChange()
if m.top.state = "loading"
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
m.busySpinner.control = "start"
else if m.top.state = "failed"
m.busySpinner.poster.uri = "pkg:/images/icons/test-failed.png"
m.busySpinner.control = "stop"
m.busySpinner.poster.rotation = 0
else if m.top.state = "passed"
m.busySpinner.poster.uri = "pkg:/images/icons/test-passed.png"
m.busySpinner.control = "stop"
m.busySpinner.poster.rotation = 0
end if
end function
function OnItemHasFocusChange() as void
if m.top.itemContent = invalid
m.detailsLabel.visible = false
return
end if
m.detailsLabel.visible = m.top.itemHasFocus and not StringUtils.IsNullOrEmpty(m.top.itemContent.details)
end function
function OnFocusPercentChange() as void
if m.top.itemContent = invalid or not m.top.gridHasFocus
m.detailsLabel.visible = false
return
end if
m.detailsLabel.visible = m.top.focusPercent > 0.5 and not StringUtils.IsNullOrEmpty(m.top.itemContent.details)
end function
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="InvidiousInstanceTestingItem" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="state" type="string" onChange="OnStateChange" />
<field id="gridHasFocus" type="boolean" />
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocusChange" />
<field id="focusPercent" type="float" onChange="OnFocusPercentChange" />
</interface>
<children>
<BusySpinner
id="busySpinner"
translation="[5,0]" />
<Label
id="nameLabel"
width="450"
translation="[60,10]" />
<Label
id="detailsLabel"
visible="false"
horizAlign="right"
width="300"
text="Press 'OK' for details"
translation="[560,10]" />
</children>
</component>
@@ -0,0 +1,238 @@
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
@asynctask
function InvidiousInstanceTestingTask(input as object) as object
instance = input.instance
listNode = input.listNode
if m.top.cancel
return invalid
end if
content = PrepareTests()
listNode.content = content
RunTests(instance, content)
return invalid
end function
function PrepareTests() as object
content = CreateObject("roSGNode", "ContentNode")
content.AppendChild(CreateTestNode("Valid url", IsValidUrl))
content.AppendChild(CreateTestNode("Instance reachable", IsReachable))
content.AppendChild(CreateTestNode("Fetch video details", CanFetchVideoDetails))
content.AppendChild(CreateTestNode("Fetch video comments", CanFetchVideoComments))
content.AppendChild(CreateTestNode("Fetch video captions", CanFetchVideoCaptions))
return content
end function
function CreateTestNode(title as string, func as function) as object
testNode = CreateObject("roSGNode", "ContentNode")
testNode.title = title
testNode.AddFields({
func: FuncName(func),
state: "loading",
details: "",
duration: 0
})
m[testNode.func] = func
return testNode
end function
function RunTests(instance as string, content as object) as void
testNodes = content.getChildren(-1, 0)
timer = CreateObject("roTimespan")
for each testNode in testNodes
timer.Mark()
m[testNode.func](instance, testNode)
testNode.duration = timer.TotalMilliseconds()
if m.top.cancel
return
end if
end for
end function
function IsValidUrl(instance as string, testNode as object) as void
try
if not instance.StartsWith("http://") and not instance.StartsWith("https://")
testNode.state = "failed"
testNode.details = "Url must start with http:// or https://"
return
end if
if instance.EndsWith("/")
testNode.state = "failed"
testNode.details = "Url must not end with /"
return
end if
testNode.state = "passed"
testNode.details = "The url seems to be of a valid format"
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
end try
end function
function IsReachable(instance as string, testNode as object) as void
try
url = `${instance}${Invidious.STATS_ENDPOINT}`
response = HttpClient.Get(url).NoCache().Await()
if not response.IsSuccess()
testNode.state = "failed"
testNode.details = response.ErrorMessage()
return
end if
json = response.Json()
if json = invalid
testNode.state = "failed"
testNode.details = `Invalid json from ${url}`
return
end if
name = json.software?.name
if not IsString(name)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read software.name)`
return
end if
version = json.software?.version
if not IsString(version)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read software.version)`
return
end if
testNode.state = "passed"
testNode.details = `The instance is reachable and running ${name} version ${version}`
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
end try
end function
function CanFetchVideoDetails(instance as string, testNode as object) as void
try
videoId = "jNQXAC9IVRw"
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
response = HttpClient.Get(url).NoCache().Await()
if not response.IsSuccess()
testNode.state = "failed"
testNode.details = response.ErrorMessage()
return
end if
json = response.Json()
if json = invalid
testNode.state = "failed"
testNode.details = `Invalid json from ${url}`
return
end if
title = json.title
if not IsString(title)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read title)`
return
end if
testNode.state = "passed"
testNode.details = `The instance can fetch video details for id "${videoId}" (${title})`
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
end try
end function
function CanFetchVideoComments(instance as string, testNode as object) as void
try
videoId = "jNQXAC9IVRw"
url = `${instance}/api/v1/comments/${videoId}`
response = HttpClient.Get(url).NoCache().Await()
if not response.IsSuccess()
testNode.state = "failed"
testNode.details = response.ErrorMessage()
return
end if
json = response.Json()
if json = invalid
testNode.state = "failed"
testNode.details = `Invalid json from ${url}`
return
end if
commentCount = json.commentCount
if not IsInt(commentCount)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read commentCount)`
return
end if
comments = json.comments
if not IsArray(comments)
testNode.state = "failed"
testNode.details = `Invalid json from ${url} (couldn't read comments)`
return
end if
testNode.state = "passed"
testNode.details = `The instance can fetch video comments for id "${videoId}" (${commentCount} comments)`
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
end try
end function
function CanFetchVideoCaptions(instance as string, testNode as object) as void
try
videoId = "jNQXAC9IVRw"
label = "English"
url = `${instance}/api/v1/captions/${videoId}?label=${label}`
response = HttpClient.Get(url).NoCache().Await()
if not response.IsSuccess()
testNode.state = "failed"
testNode.details = response.ErrorMessage()
return
end if
headers = response.Headers()
contentType = headers["Content-Type"]
if StringUtils.IsNullOrEmpty(contentType) or not contentType.StartsWith("text/vtt")
testNode.state = "failed"
testNode.details = `Invalid caption data ${url} (Content-Type is not text/vtt)`
return
end if
text = response.Text()
if StringUtils.IsNullOrEmpty(text) or not text.StartsWith("WEBVTT")
testNode.state = "failed"
testNode.details = `Invalid caption data from ${url} (response is not a valid vtt file)`
return
end if
if text.InStr(`All right, so here we are, in front of the\nelephants`) = -1
testNode.state = "failed"
testNode.details = `Did not find expected text in caption data from ${url}`
return
end if
testNode.state = "passed"
testNode.details = `The instance can fetch video ${label} captions for id "${videoId}"`
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
end try
end function