Skip to content

Commit

Permalink
fix bilibili cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
hr3lxphr6j committed Feb 12, 2022
1 parent 1fa316b commit 3c888e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/live/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ func (l *Live) parseRealId() error {
if len(paths) < 2 {
return live.ErrRoomUrlIncorrect
}
resp, err := requests.Get(roomInitUrl, live.CommonUserAgent, requests.Query("id", paths[1]))
cookies := l.Options.Cookies.Cookies(l.Url)
cookieKVs := make(map[string]string)
for _, item := range cookies {
cookieKVs[item.Name] = item.Value
}
resp, err := requests.Get(roomInitUrl, live.CommonUserAgent, requests.Query("id", paths[1]), requests.Cookies(cookieKVs))
if err != nil {
return err
}
Expand Down Expand Up @@ -124,11 +129,16 @@ func (l *Live) GetStreamUrls() (us []*url.URL, err error) {
return nil, err
}
}
cookies := l.Options.Cookies.Cookies(l.Url)
cookieKVs := make(map[string]string)
for _, item := range cookies {
cookieKVs[item.Name] = item.Value
}
resp, err := requests.Get(liveApiUrl, live.CommonUserAgent, requests.Queries(map[string]string{
"cid": l.realID,
"quality": "4",
"platform": "web",
}))
}), requests.Cookies(cookieKVs))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3c888e2

Please sign in to comment.