Skip to content

Commit

Permalink
fix huya 获取真实roomid
Browse files Browse the repository at this point in the history
  • Loading branch information
redstone1994 committed Jul 9, 2024
1 parent e7c9d86 commit 39c1094
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/live/huya/huya.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/tidwall/gjson"
"net/http"
"net/url"
"strings"
)

const (
Expand Down Expand Up @@ -39,7 +38,22 @@ type Live struct {
}

func (l *Live) getDate() (result *gjson.Result, err error) {
roomId := strings.Trim(l.Url.Path, "/")
html, err := requests.Get(l.Url.String(), live.CommonUserAgent)
if err != nil {
return nil, err
}
if html.StatusCode != http.StatusOK {
return nil, live.ErrRoomNotExist
}
htmlBody, err := html.Text()
if err != nil {
return nil, err
}
strFilter := utils.NewStringFilterChain(utils.ParseUnicode, utils.UnescapeHTMLEntity)
rjson := strFilter.Do(utils.Match1(`stream: (\{"data".*?),"iWebDefaultBitRate"`, htmlBody)) + "}"
gj := gjson.Parse(rjson)

roomId := gj.Get("data.0.gameLiveInfo.profileRoom").String()
params := make(map[string]string)
params["m"] = "Live"
params["do"] = "profileRoom"
Expand Down

0 comments on commit 39c1094

Please sign in to comment.