From e5d77e86ff5ce1ba848b27c76a8c05f351e8c178 Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Sat, 12 Feb 2022 13:04:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=BC=95=E6=93=8E=E5=8F=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index c343219..9db0952 100644 --- a/main.go +++ b/main.go @@ -25,35 +25,33 @@ type HDLConfig struct { var streamPathReg = regexp.MustCompile(`/(hdl/)?((.+)(\.flv)|(.+))`) -func (config *HDLConfig) Update(override config.Config) { - if config.ListenAddr != "" || config.ListenAddrTLS != "" { - plugin.Infoln(Green("HDL Listen at "), BrightBlue(config.ListenAddr), BrightBlue(config.ListenAddrTLS)) - config.Listen(plugin, config) +func (c *HDLConfig) Update(override config.Config) { + if c.ListenAddr != "" || c.ListenAddrTLS != "" { + plugin.Infoln(Green("HDL Listen at "), BrightBlue(c.ListenAddr), BrightBlue(c.ListenAddrTLS)) + 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") 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 config.AutoPullList == nil { - config.AutoPullList = make(map[string]string) - } - config.AutoPullList[streamPath] = targetURL + c.AddPull(streamPath, targetURL) + plugin.Modified["pull"] = c.Pull if err := plugin.Save(); err != nil { 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) } var Config = new(HDLConfig) 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) if len(parts) == 0 { w.WriteHeader(404)