fix: pull add reg match

This commit is contained in:
langhuihui
2025-01-12 21:55:42 +08:00
parent d80dac852b
commit af2a7ccf5f
3 changed files with 14 additions and 14 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ mp4:
onsub:
pull:
^vod\d+/(.+)/mp4$: $1
^vod_mp4_\d+/(.+)$: $1
cascadeserver:
quic:
listenaddr: :44944
@@ -43,7 +43,7 @@ flv:
# filepath: record/$0
onsub:
pull:
^vod\d+/(.+)/flv$: $1
^vod_flv_\d+/(.+)$: $1
# pull:
# live/test: https://livecb.alicdn.com/mediaplatform/afb241b3-408c-42dd-b665-04d22b64f9df.flv?auth_key=1734575216-0-0-c62721303ce751c8e5b2c95a2ec242a0&F=pc&source=34675810_null_live_detail&ali_flv_retain=2
hls:
+10 -10
View File
@@ -57,21 +57,21 @@ type (
Key string `desc:"订阅鉴权key"` // 订阅鉴权key
SubType string `desc:"订阅类型"` // 订阅类型
}
HTTPValus map[string][]string
Pull struct {
HTTPValues map[string][]string
Pull struct {
URL string `desc:"拉流地址"`
MaxRetry int `default:"-1" desc:"断开后自动重试次数,0:不重试,-1:无限重试"` // 断开后自动重拉,0 表示不自动重拉,-1 表示无限重拉,高于0 的数代表最大重拉次数
RetryInterval time.Duration `default:"5s" desc:"重试间隔"` // 重试间隔
Proxy string `desc:"代理地址"` // 代理地址
Header HTTPValus
Args HTTPValus `gorm:"-:all"` // 拉流参数
Header HTTPValues
Args HTTPValues `gorm:"-:all"` // 拉流参数
}
Push struct {
URL string `desc:"推送地址"` // 推送地址
MaxRetry int `desc:"断开后自动重试次数,0:不重试,-1:无限重试"` // 断开后自动重推,0 表示不自动重推,-1 表示无限重推,高于0 的数代表最大重推次数
RetryInterval time.Duration `default:"5s" desc:"重试间隔"` // 重试间隔
Proxy string `desc:"代理地址"` // 代理地址
Header HTTPValus
Header HTTPValues
}
Record struct {
FilePath string `desc:"录制文件路径"` // 录制文件路径
@@ -139,7 +139,7 @@ func (p *Record) GetRecordConfig() *Record {
return p
}
func (v *HTTPValus) Scan(value any) error {
func (v *HTTPValues) Scan(value any) error {
bytes, ok := value.([]byte)
if !ok {
return fmt.Errorf("failed to unmarshal yaml value: %v", value)
@@ -147,16 +147,16 @@ func (v *HTTPValus) Scan(value any) error {
return yaml.Unmarshal(bytes, v)
}
func (v HTTPValus) Value() (driver.Value, error) {
func (v HTTPValues) Value() (driver.Value, error) {
return yaml.Marshal(v)
}
func (v HTTPValus) Get(key string) string {
func (v HTTPValues) Get(key string) string {
return url.Values(v).Get(key)
}
func (v HTTPValus) DeepClone() (ret HTTPValus) {
ret = make(HTTPValus)
func (v HTTPValues) DeepClone() (ret HTTPValues) {
ret = make(HTTPValues)
for k, v := range v {
ret[k] = append([]string(nil), v...)
}
+2 -2
View File
@@ -531,8 +531,8 @@ func (p *Plugin) OnSubscribe(streamPath string, args url.Values) {
// }
// }
for reg, conf := range p.config.OnSub.Pull {
if p.Meta.Puller != nil {
conf.Args = config.HTTPValus(args)
if p.Meta.Puller != nil && reg.MatchString(streamPath) {
conf.Args = config.HTTPValues(args)
conf.URL = reg.Replace(streamPath, conf.URL)
p.handler.Pull(streamPath, conf, nil)
}