lru
This commit is contained in:
		@@ -7,6 +7,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	openapi "github.com/alibabacloud-go/darabonba-openapi/client"
 | 
			
		||||
@@ -21,6 +22,7 @@ var (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody, err error) {
 | 
			
		||||
	// 判断是否为视频地址
 | 
			
		||||
	if len(imageRegexp.FindStringSubmatch(content)) > 0 {
 | 
			
		||||
		key := urlRegexp.ReplaceAllString(content, "")
 | 
			
		||||
		// 连接点播服务的OSS
 | 
			
		||||
@@ -32,13 +34,20 @@ func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody
 | 
			
		||||
		if _err != nil {
 | 
			
		||||
			return nil, _err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 将 key 中的空格转码
 | 
			
		||||
		key = strings.Replace(key, " ", "%20", -1)
 | 
			
		||||
 | 
			
		||||
		// 通过标题查询视频ID
 | 
			
		||||
		log.Println("查询视频", key)
 | 
			
		||||
		response, _err := client.SearchMedia(&vod20170321.SearchMediaRequest{
 | 
			
		||||
			Match: tea.String(fmt.Sprintf("Title='%s'", key)),
 | 
			
		||||
		})
 | 
			
		||||
		if _err != nil {
 | 
			
		||||
			return nil, _err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Println("查询视频结果", response.Body)
 | 
			
		||||
		if len(response.Body.MediaList) > 0 && *response.Body.MediaList[0].MediaType == "video" {
 | 
			
		||||
			// 通过ID查询视频播放地址
 | 
			
		||||
			VideoId := response.Body.MediaList[0].Video.VideoId
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user