减少正则表达式的编译,提高运行效率
This commit is contained in:
		@@ -15,9 +15,14 @@ import (
 | 
				
			|||||||
	"github.com/spf13/viper"
 | 
						"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) {
 | 
					func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody, err error) {
 | 
				
			||||||
	if len(regexp.MustCompile(`image.gameuiux.cn`).FindStringSubmatch(content)) > 0 {
 | 
						if len(imageRegexp.FindStringSubmatch(content)) > 0 {
 | 
				
			||||||
		key := regexp.MustCompile(`^https?://image.gameuiux.cn/`).ReplaceAllString(content, "")
 | 
							key := urlRegexp.ReplaceAllString(content, "")
 | 
				
			||||||
		// 连接点播服务的OSS
 | 
							// 连接点播服务的OSS
 | 
				
			||||||
		client, _err := vod20170321.NewClient(&openapi.Config{
 | 
							client, _err := vod20170321.NewClient(&openapi.Config{
 | 
				
			||||||
			AccessKeyId:     tea.String(viper.GetString("video.accessID")),
 | 
								AccessKeyId:     tea.String(viper.GetString("video.accessID")),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user