Sign app for publishing (#38)
* Sign app for publishing * update gitignore * refactor input args * Change instance api sorting * Better instance sorting * Instance filter * remove hardcoded instance * script cleanups * Unused function
This commit is contained in:
1 parent
4640a34863
commit
7a155c689e
15 files changed
+636
-252
No files matched your search
@@ -108,18 +108,28 @@ function GetIndexOfChild(parent as object, childId as string) as integer
|
||||
return -1
|
||||
end function
|
||||
|
||||
function LaunchArgumentsReceived()
|
||||
function LaunchArgumentsReceived() as void
|
||||
? "LaunchArgumentsReceived" m.top.launchArgs
|
||||
if m.top.launchArgs <> invalid and m.top.launchArgs.contentId <> invalid
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(m.top.launchArgs.contentId, { sender: sender })
|
||||
end if
|
||||
PlayVideoFromArgs(m.top.launchArgs)
|
||||
end function
|
||||
|
||||
function InputArgumentsReceived()
|
||||
function InputArgumentsReceived() as void
|
||||
? "InputArgumentsReceived" m.top.inputArgs
|
||||
if m.top.inputArgs <> invalid and m.top.inputArgs.contentId <> invalid
|
||||
PlayVideoFromArgs(m.top.inputArgs)
|
||||
end function
|
||||
|
||||
function PlayVideoFromArgs(args as object) as void
|
||||
if args = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
contentId = args.contentId
|
||||
' mediaType is not unused, not putting it here fails validation
|
||||
' bs:disable-next-line
|
||||
mediaType = args.mediaType
|
||||
|
||||
if contentId <> invalid
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(m.top.inputArgs.contentId, { sender: sender })
|
||||
PlayVideo(contentId, { sender: sender })
|
||||
end if
|
||||
end function
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -22,6 +22,8 @@ function main(args as object) as void
|
||||
|
||||
scene = screen.CreateScene("MainScene")
|
||||
screen.show()
|
||||
scene.signalBeacon("AppLaunchComplete")
|
||||
|
||||
scene.ObserveField("exitChannel", m.port)
|
||||
scene.launchArgs = args
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Invidious
|
||||
webServerPort = 8888
|
||||
expire = TimeUtils.Now().AsSeconds() + 60 * 60 * 24 * 365 * 2 '2 years from now
|
||||
|
||||
callbackUrl = WebUtils.UrlEncode(`http://${localIp}:${webServerPort}${Invidious.TOKEN_CALLBACK}?referer=${instance}`)
|
||||
callbackUrl = WebUtils.UrlEscape(`http://${localIp}:${webServerPort}${Invidious.TOKEN_CALLBACK}?referer=${instance}`)
|
||||
return `${invidiousHost}/authorize_token?scopes=${Invidious.AUTH_SCOPE}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
end function
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace InvidiousSettings
|
||||
|
||||
const DEFAULT_INSTANCE = "https://vid.puffyan.us"
|
||||
|
||||
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,health,users,api"
|
||||
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
|
||||
|
||||
function GetCurrentInstances() as object
|
||||
' TODO: cache this call to avoid json parsing every time
|
||||
@@ -13,10 +13,13 @@ namespace InvidiousSettings
|
||||
|
||||
publicInstances = InvidiousSettings.GetPublicInstances()
|
||||
if publicInstances <> invalid
|
||||
for i = 0 to 4
|
||||
if i < publicInstances.Count()
|
||||
for i = 0 to publicInstances.Count() - 1
|
||||
if InvidiousSettings.IsValidPublicInstance(publicInstances[i])
|
||||
instances.push(publicInstances[i].uri)
|
||||
end if
|
||||
if instances.Count() >= 5
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
@@ -72,10 +75,8 @@ namespace InvidiousSettings
|
||||
if m.invidiousPublicInstances <> invalid
|
||||
return m.invidiousPublicInstances
|
||||
end if
|
||||
args = {
|
||||
cacheSeconds: 60 * 60 * 6 ' 6 hours
|
||||
}
|
||||
response = Requests().get(InvidiousSettings.INSTANCES_API, args)
|
||||
|
||||
response = Requests().get(InvidiousSettings.INSTANCES_API)
|
||||
if response.statuscode = 200
|
||||
json = response.json
|
||||
instances = []
|
||||
@@ -95,4 +96,12 @@ namespace InvidiousSettings
|
||||
return m.invidiousPublicInstances
|
||||
end function
|
||||
|
||||
function IsValidPublicInstance(instance as object) as boolean
|
||||
if instance = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
return instance.type = "https" and instance.api = true
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,15 +1,6 @@
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace WebUtils
|
||||
function UrlEncode(url as string) as string
|
||||
ue = m.UrlEncoder
|
||||
if ue = invalid
|
||||
ue = CreateObject("roUrlTransfer")
|
||||
m.UrlEncoder = ue
|
||||
end if
|
||||
return ue.UrlEncode(url)
|
||||
end function
|
||||
|
||||
function UrlEscape(url as string) as string
|
||||
ue = m.UrlEncoder
|
||||
if ue = invalid
|
||||
|
||||
Reference in new issue
Block a user