package live
import (
"GetRelLiveUrl/utils"
"encoding/json"
"fmt"
"net/http"
"regexp"
"strings"
)
type Dy struct {
Data struct {
Room struct {
StreamURL struct {
RtmpPullURL string `json:"rtmp_pull_url"`
HlsPullURL string `json:"hls_pull_url"`
} `json:"stream_url"`
} `json:"room"`
} `json:"data"`
}
func getRoomid(text string) string {
var roomid string
if strings.Contains(text, "v.douyin.com") {
urlreg := `[a-zA-z]+://[^\s]*`
compile := regexp.MustCompile(urlreg)
submatch := compile.FindAllStringSubmatch(text, -1)
url := submatch[0][0]
resp, _ := http.Get(url)
relurl := resp.Request.URL.String()
roomidReg := `(\d{19})`
compile2 := regexp.MustCompile(roomidReg)
submatch2 := compile2.FindAllStringSubmatch(relurl, -1)
roomid = submatch2[0][0]
} else {
return ""
}
return roomid
}
func Getrelrul(text string) string {
roomid:=getRoomid(text)
newurl := fmt.Sprintf("https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id=%s&live_id=1", roomid)
jsonstr := utils.GetData(newurl)
var dy Dy
json.Unmarshal([]byte(jsonstr), &dy)
relurl := "flv:\n"+dy.Data.Room.StreamURL.RtmpPullURL +"\n\nm3u8:\n" +dy.Data.Room.StreamURL.HlsPullURL
return relurl
}
go语言抖音直播真实地址提取
最新推荐文章于 2024-04-02 19:52:42 发布