Skip to content

Commit

Permalink
fixed: 修复抖音无法获取监控信息的问题 (#630)
Browse files Browse the repository at this point in the history
* fixed: 修复抖音无法获取监控信息的问题

* 修复配置中的抖音cookie会被覆盖的问题

---------

Co-authored-by: hucaloof <[email protected]>
Co-authored-by: kira1928 <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2023
1 parent 055765c commit 981d95a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/live/douyin/douyin.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func createRandomCookie() string {
return utils.GenRandomString(21, randomCookieChars)
}

func createRandomOdintt() string {
return utils.GenRandomString(160, randomCookieChars)
}

type Live struct {
internal.BaseLive
responseCookies map[string]string
Expand All @@ -66,12 +70,13 @@ func (l *Live) getLiveRoomWebPageResponse() (body string, err error) {
}

// proxy, _ := url.Parse("http://localhost:8888")
// resp, err := requests.NewSession(&http.Client{
// Transport: &http.Transport{
// Proxy: http.ProxyURL(proxy),
// },
// }).Get(
resp, err := requests.Get(
requestSession := requests.NewSession(&http.Client{
// Transport: &http.Transport{
// Proxy: http.ProxyURL(proxy),
// },
})
req, err := requests.NewRequest(
http.MethodGet,
l.Url.String(),
live.CommonUserAgent,
requests.Cookies(cookieKVs),
Expand All @@ -82,6 +87,12 @@ func (l *Live) getLiveRoomWebPageResponse() (body string, err error) {
if err != nil {
return
}
cookieWithOdinTt := fmt.Sprintf("odin_tt=%s; %s", createRandomOdintt(), req.Header.Get("Cookie"))
req.Header.Set("Cookie", cookieWithOdinTt)
resp, err := requestSession.Do(req)
if err != nil {
return
}
switch code := resp.StatusCode; code {
case http.StatusOK:
for _, cookie := range resp.Cookies() {
Expand Down

0 comments on commit 981d95a

Please sign in to comment.