减少正则表达式的编译,提高运行效率

This commit is contained in:
2023-11-21 04:21:21 +08:00
parent f6bfbca1fd
commit e55404ad87

View File

@@ -15,9 +15,14 @@ import (
"github.com/spf13/viper"
)
var (
imageRegexp = regexp.MustCompile(`image.gameuiux.cn`)
urlRegexp = regexp.MustCompile(`^https?://image.gameuiux.cn/`)
)
func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody, err error) {
if len(regexp.MustCompile(`image.gameuiux.cn`).FindStringSubmatch(content)) > 0 {
key := regexp.MustCompile(`^https?://image.gameuiux.cn/`).ReplaceAllString(content, "")
if len(imageRegexp.FindStringSubmatch(content)) > 0 {
key := urlRegexp.ReplaceAllString(content, "")
// 连接点播服务的OSS
client, _err := vod20170321.NewClient(&openapi.Config{
AccessKeyId: tea.String(viper.GetString("video.accessID")),