1 parent
8975861615
commit
549913ef7d
14 files changed
+129
-20
No files matched your search
@@ -1,7 +1,10 @@
|
||||
namespace ChannelUtils
|
||||
function Open(contentNode as object)
|
||||
function Open(contentNode as object, appController = invalid as object)
|
||||
channelView = CreateObject("roSGNode", "ChannelView")
|
||||
m.appController@.PushScreen(channelView)
|
||||
if appController = invalid
|
||||
appController = m.appController
|
||||
end if
|
||||
appController@.PushScreen(channelView)
|
||||
channelView@.BindNode(invalid)
|
||||
channelView.content = contentNode
|
||||
end function
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<PlayletWebServer
|
||||
id="WebServer"
|
||||
port="8888"
|
||||
appController="bind:/AppController"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
invidious="bind:../Invidious"
|
||||
preferences="bind:../Preferences"
|
||||
|
||||
@@ -21,6 +21,7 @@ function InitializeBindings()
|
||||
"preferences": "../Preferences"
|
||||
},
|
||||
"WebServer": {
|
||||
"appController": "/AppController",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"invidious": "../Invidious",
|
||||
"preferences": "../Preferences",
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
namespace PlaylistUtils
|
||||
function Open(contentNode as object)
|
||||
function Open(contentNode as object, appController = invalid as object)
|
||||
playlistView = CreateObject("roSGNode", "PlaylistView")
|
||||
m.appController@.PushScreen(playlistView)
|
||||
if appController = invalid
|
||||
appController = m.appController
|
||||
end if
|
||||
appController@.PushScreen(playlistView)
|
||||
playlistView@.BindNode(invalid)
|
||||
playlistView.content = contentNode
|
||||
end function
|
||||
|
||||
@@ -58,6 +58,14 @@ namespace VideoUtils
|
||||
return m.top.getScene().findNode("VideoContainer")
|
||||
end function
|
||||
|
||||
function IsVideoPlayerFullScreen() as boolean
|
||||
videoContainer = GetVideoContainer()
|
||||
if videoContainer = invalid
|
||||
return false
|
||||
end if
|
||||
return videoContainer.fullscreen
|
||||
end function
|
||||
|
||||
function ToggleVideoPictureInPicture() as boolean
|
||||
videoPlayer = GetVideoPlayer()
|
||||
if videoPlayer = invalid
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Http
|
||||
|
||||
' This is an endpoint allowing the web app to make an authenticated request
|
||||
' without needing the Invidious token
|
||||
' TODO:P2 this should be a POST request
|
||||
' This is a GET not a POST for better caching
|
||||
m.Get("/invidious/authenticated-request", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
class ViewRouter extends HttpRouter
|
||||
|
||||
function new()
|
||||
super()
|
||||
|
||||
m.Get("/api/view/open", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
appController = context.server.task.appController
|
||||
|
||||
playlistId = request.query.playlistId
|
||||
authorId = request.query.authorId
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(playlistId)
|
||||
contentNode = InvidiousContent.ToPlaylistContentNode(invalid, { playlistId: playlistId }, invalid)
|
||||
PlaylistUtils.Open(contentNode, appController)
|
||||
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
|
||||
VideoUtils.ToggleVideoPictureInPicture()
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
else if not StringUtils.IsNullOrEmpty(authorId)
|
||||
contentNode = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
|
||||
ChannelUtils.Open(contentNode, appController)
|
||||
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
|
||||
VideoUtils.ToggleVideoPictureInPicture()
|
||||
end if
|
||||
response.Default(204, "OK")
|
||||
else
|
||||
response.Default(400, "Invalid request")
|
||||
end if
|
||||
|
||||
return true
|
||||
end function)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -6,6 +6,7 @@ import "pkg:/components/Web/PlayletWebServer/Middleware/PlayQueueRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PreferencesRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/StateApiRouter.bs"
|
||||
import "pkg:/components/Web/PlayletWebServer/Middleware/ViewRouter.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/CorsMiddleware.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/EtagMiddleware.bs"
|
||||
import "pkg:/components/Web/WebServer/Middleware/HttpStaticFilesRouter.bs"
|
||||
@@ -40,6 +41,7 @@ function SetupRoutes(server as object)
|
||||
server.UseRouter(new Http.InvidiousRouter())
|
||||
server.UseRouter(new Http.PlayQueueRouter())
|
||||
server.UseRouter(new Http.BookmarksRouter())
|
||||
server.UseRouter(new Http.ViewRouter())
|
||||
server.UseRouter(new Http.SearchHistoryRouter())
|
||||
server.UseRouter(new Http.PlayletLibUrlsRouter())
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<component name="PlayletWebServer" extends="WebServer" includes="AutoBind">
|
||||
<interface>
|
||||
<field id="appController" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="invidious" type="node" />
|
||||
<field id="applicationInfo" type="node" />
|
||||
|
||||
Reference in new issue
Block a user