mirror of
https://github.com/Monibuca/plugin-hdl.git
synced 2025-10-05 16:56:55 +08:00
适配引擎变化
This commit is contained in:
22
main.go
22
main.go
@@ -25,35 +25,33 @@ type HDLConfig struct {
|
|||||||
|
|
||||||
var streamPathReg = regexp.MustCompile(`/(hdl/)?((.+)(\.flv)|(.+))`)
|
var streamPathReg = regexp.MustCompile(`/(hdl/)?((.+)(\.flv)|(.+))`)
|
||||||
|
|
||||||
func (config *HDLConfig) Update(override config.Config) {
|
func (c *HDLConfig) Update(override config.Config) {
|
||||||
if config.ListenAddr != "" || config.ListenAddrTLS != "" {
|
if c.ListenAddr != "" || c.ListenAddrTLS != "" {
|
||||||
plugin.Infoln(Green("HDL Listen at "), BrightBlue(config.ListenAddr), BrightBlue(config.ListenAddrTLS))
|
plugin.Infoln(Green("HDL Listen at "), BrightBlue(c.ListenAddr), BrightBlue(c.ListenAddrTLS))
|
||||||
config.Listen(plugin, config)
|
c.Listen(plugin, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (config *HDLConfig) API_Pull(rw http.ResponseWriter, r *http.Request) {
|
func (c *HDLConfig) API_Pull(rw http.ResponseWriter, r *http.Request) {
|
||||||
targetURL := r.URL.Query().Get("target")
|
targetURL := r.URL.Query().Get("target")
|
||||||
streamPath := r.URL.Query().Get("streamPath")
|
streamPath := r.URL.Query().Get("streamPath")
|
||||||
if config.PullStream(streamPath, Puller{RemoteURL: targetURL, Config: &config.Pull}) {
|
if c.PullStream(streamPath, Puller{RemoteURL: targetURL, Config: &c.Pull}) {
|
||||||
if r.URL.Query().Get("save") != "" {
|
if r.URL.Query().Get("save") != "" {
|
||||||
if config.AutoPullList == nil {
|
c.AddPull(streamPath, targetURL)
|
||||||
config.AutoPullList = make(map[string]string)
|
plugin.Modified["pull"] = c.Pull
|
||||||
}
|
|
||||||
config.AutoPullList[streamPath] = targetURL
|
|
||||||
if err := plugin.Save(); err != nil {
|
if err := plugin.Save(); err != nil {
|
||||||
plugin.Errorln(err)
|
plugin.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (config *HDLConfig) API_List(rw http.ResponseWriter, r *http.Request) {
|
func (*HDLConfig) API_List(rw http.ResponseWriter, r *http.Request) {
|
||||||
util.ReturnJson(FilterStreams[*HDLPuller], time.Second, rw, r)
|
util.ReturnJson(FilterStreams[*HDLPuller], time.Second, rw, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
var Config = new(HDLConfig)
|
var Config = new(HDLConfig)
|
||||||
var plugin = InstallPlugin(Config)
|
var plugin = InstallPlugin(Config)
|
||||||
|
|
||||||
func (config *HDLConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (*HDLConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
parts := streamPathReg.FindStringSubmatch(r.RequestURI)
|
parts := streamPathReg.FindStringSubmatch(r.RequestURI)
|
||||||
if len(parts) == 0 {
|
if len(parts) == 0 {
|
||||||
w.WriteHeader(404)
|
w.WriteHeader(404)
|
||||||
|
Reference in New Issue
Block a user