mirror of
https://github.com/Monibuca/plugin-preview.git
synced 2025-09-26 19:11:14 +08:00
增加罗列按需拉流的列表
This commit is contained in:
22
main.go
22
main.go
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
. "m7s.live/engine/v4"
|
||||
"m7s.live/engine/v4/config"
|
||||
)
|
||||
|
||||
//go:embed ui
|
||||
@@ -21,13 +22,28 @@ func (p *PreviewConfig) OnEvent(event any) {
|
||||
|
||||
}
|
||||
|
||||
var plugin = InstallPlugin(&PreviewConfig{})
|
||||
var _ = InstallPlugin(&PreviewConfig{})
|
||||
|
||||
func (p *PreviewConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/preview/" {
|
||||
Streams.Range(func(streamPath string, s *Stream) {
|
||||
w.Write([]byte(fmt.Sprintf("<a href='%s'>%s</a><br>", streamPath, streamPath)))
|
||||
var s string
|
||||
Streams.Range(func(streamPath string, _ *Stream) {
|
||||
s += fmt.Sprintf("<a href='%s'>%s</a><br>", streamPath, streamPath)
|
||||
})
|
||||
if s != "" {
|
||||
s = "<b>Live Streams</b><br>" + s
|
||||
}
|
||||
for name, p := range Plugins {
|
||||
if pullcfg, ok := p.Config.(config.PullConfig); ok {
|
||||
if pullonsub := pullcfg.GetPullConfig().PullOnSub; pullonsub != nil {
|
||||
s += fmt.Sprintf("<b>%s pull stream on subscribe</b><br>", name)
|
||||
for streamPath, url := range pullonsub {
|
||||
s += fmt.Sprintf("<a href='%s'>%s</a> <-- %s<br>", streamPath, streamPath, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
w.Write([]byte(s))
|
||||
return
|
||||
}
|
||||
ss := strings.Split(r.URL.Path, "/")
|
||||
|
Reference in New Issue
Block a user