Files
playlet-piped/playlet-lib/src/components/Web/PlayletWebServer/PlayletWebServer.bs
T
Brahim Hadricheandgithub-action linter 7d1ba07286 Cast using Youtube app (DIAL/LoungeAPI) (#276)
* Dial+Lounge API PoC

* format

* Fix for chrome

* comments

* Rate limit and logger stuff

* rename route

* remove invalid routes

* remove device image

* Simplify device description

* command test

* Lint fix

* register pairing code

* tv code UI

* Lint fix

* Avoid creating lots of objects

* dpad command

* small refactor

* tweak

* validation

* timer

* fix

* Revert "timer"

This reverts commit e349565910882408898c9bddda55dadaa9d743de.

* Commands

* setVolume command

* lounge service timer

* Some state messages

* Lint fix

* player state sync

* voice handler

* Adjustments, and add a TODO list

* Lint fix

* comment

* play at timestamp

* Remote screen UI

* UI adjustment

* Small refactor

* Refactor long polling

* Add TODO

* Manage logging a bit better to avoid spam in DIAL server

* cache dial file

* logging

* comment

* Join lounge lazily

* long poller tweak

* ui tweak

* set shouldQuit field

* remote connect notification

* Lint fix

* Randomize device id, new device on start

* Lint fix

* Lounge disconnect on start

* Speed up lounge by not blocking on sent messages

* add version to lounge data saved

* dial server fix rendezvous

* todo

* no message

* Display network name

* playlist changes

* Lint fix

* tweak params

* tweak

* player state

* comments

* Refactor Video Queue (#295)

* Refactor Video Queue

* Video queue and playlists

* Web app casting

* queue playlist notification

* VideoQueueView work

* restore properties

* changes

* queue notification and previous/next state

* Lint fix

* very basic error handling

* Update changelog and privacy policy

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2024-02-19 16:30:48 -05:00

72 lines
3.9 KiB
Plaintext

import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/DashRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/DialRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/HomeLayoutRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/HomeRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/PreferencesRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/RegistryRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/SearchHistoryRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/StateApiRouter.bs"
import "pkg:/components/Web/PlayletWebServer/Middleware/VideoQueueRouter.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"
import "pkg:/components/Web/WebServer/WebSockets/WebSocketMiddleware.bs"
function Init()
m.top.packageName = "Playlet"
m.top.serverName = "Playlet Web Server"
end function
function GetServerAddress(_unused as dynamic) as dynamic
port = m.top.port
ip = m.top.applicationInfo@.GetLocalIpAddress()
if StringUtils.IsNullOrEmpty(ip)
return invalid
end if
return `http://${ip}:${port}`
end function
function SetupRoutes(server as object)
server.UseRouter(new Http.CorsMiddleware())
if server.settings.WebSocketsEnabled
server.UseRouter(new Http.WebSocketMiddleware())
end if
server.UseRouter(new Http.HomeRouter())
server.UseRouter(new Http.StateApiRouter(server))
server.UseRouter(new Http.DashRouter(server))
server.UseRouter(new Http.PreferencesRouter(server))
server.UseRouter(new Http.InvidiousRouter(server))
server.UseRouter(new Http.VideoQueueRouter(server))
server.UseRouter(new Http.BookmarksRouter(server))
server.UseRouter(new Http.HomeLayoutRouter(server))
server.UseRouter(new Http.ViewRouter(server))
server.UseRouter(new Http.SearchHistoryRouter(server))
server.UseRouter(new Http.PlayletLibUrlsRouter(server))
server.UseRouter(new Http.DialRouter(server))
etags = new Http.EtagUtils()
server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true }))
server.UseRouter(new Http.HttpStaticFilesRouter("/config", "libpkg:/config", etags, { staticFiles: true }))
server.UseRouter(new Http.HttpStaticFilesRouter("/logs", "cachefs:/logs", etags, { fsCheck: true }))
#if DEBUG
server.UseRouter(new Http.RegistryRouter())
options = { showDirectories: true, showHidden: true, staticFiles: true }
server.UseRouter(new Http.HttpStaticFilesRouter("/debug/libpkg", "libpkg:/", etags, options))
options = { showDirectories: true, showHidden: true, fsCheck: true, staticFiles: true }
server.UseRouter(new Http.HttpStaticFilesRouter("/debug/pkg", "pkg:/", etags, options))
options = { showDirectories: true, showHidden: true, fsCheck: true }
server.UseRouter(new Http.HttpStaticFilesRouter("/debug/tmp", "tmp:/", etags, options))
options = { showDirectories: true, showHidden: true, fsCheck: true }
server.UseRouter(new Http.HttpStaticFilesRouter("/debug/cachefs", "cachefs:/", etags, options))
options = { showDirectories: true, showHidden: true, fsCheck: true, staticFiles: true }
server.UseRouter(new Http.HttpStaticFilesRouter("/debug/common", "common:/", etags, options))
#end if
server.UsePostRouter(new Http.EtagMiddleware(etags))
end function