50 lines
1.9 KiB
Plaintext
50 lines
1.9 KiB
Plaintext
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
|
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
|
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
|
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
|
|
|
namespace Http
|
|
|
|
class ViewRouter extends HttpRouter
|
|
|
|
function new(server as object)
|
|
super()
|
|
|
|
task = server.task
|
|
m.appController = task.appController
|
|
m.videoQueue = task.videoQueue
|
|
end function
|
|
|
|
@get("/api/view/open")
|
|
function OpenView(context as object) as boolean
|
|
request = context.request
|
|
response = context.response
|
|
|
|
playlistId = request.query.playlistId
|
|
authorId = request.query.authorId
|
|
|
|
if not StringUtils.IsNullOrEmpty(playlistId)
|
|
contentNode = InvidiousContent.ToPlaylistContentNode(invalid, { playlistId: playlistId }, invalid)
|
|
PlaylistUtils.Open(contentNode, m.appController)
|
|
if VideoQueueUtils.IsVideoPlayerOpen(m.videoQueue) and VideoQueueUtils.IsVideoPlayerFullScreen(m.videoQueue)
|
|
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
|
end if
|
|
response.Default(204, "OK")
|
|
else if not StringUtils.IsNullOrEmpty(authorId)
|
|
contentNode = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId })
|
|
ChannelUtils.Open(contentNode, m.appController)
|
|
if VideoQueueUtils.IsVideoPlayerOpen(m.videoQueue) and VideoQueueUtils.IsVideoPlayerFullScreen(m.videoQueue)
|
|
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
|
end if
|
|
response.Default(204, "OK")
|
|
else
|
|
response.Default(400, "Invalid request")
|
|
end if
|
|
|
|
return true
|
|
end function
|
|
|
|
end class
|
|
|
|
end namespace
|