Skip to content

Commit 82d4305

Browse files
committed
olivetv: fix youtube get failure due to req pkg
1 parent 1e2cf2a commit 82d4305

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

foundation/olivetv/huya_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func TestHuya_Snap(t *testing.T) {
10-
u := "https://www.huya.com/520588"
10+
u := "https://www.youtube.com/@ShirakamiFubuki"
1111
huya, err := tv.NewWithURL(u)
1212
if err != nil {
1313
println(err.Error())

foundation/olivetv/youtube.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package olivetv
33
import (
44
"bytes"
55
"fmt"
6+
"io"
7+
"net/http"
68
"time"
79

8-
"github.com/imroc/req/v3"
910
jsoniter "github.com/json-iterator/go"
1011
"golang.org/x/net/html"
1112
)
@@ -32,11 +33,22 @@ func (this *youtube) Snap(tv *TV) error {
3233

3334
func (this *youtube) set(tv *TV) error {
3435
liveURL := fmt.Sprintf("https://www.youtube.com/%s/live", tv.RoomID)
35-
resp, err := req.C().R().Get(liveURL)
36+
37+
// resp, err := req.C().R().Get(liveURL)
38+
// if err != nil {
39+
// return fmt.Errorf("get video url failed: %w", err)
40+
// }
41+
// videoHTML := resp.Bytes()
42+
43+
resp, err := http.Get(liveURL)
44+
if err != nil {
45+
return err
46+
}
47+
content, err := io.ReadAll(resp.Body)
3648
if err != nil {
37-
return fmt.Errorf("get video url failed: %w", err)
49+
return err
3850
}
39-
videoHTML := resp.Bytes()
51+
videoHTML := content
4052

4153
// PlayerResponse
4254
prb := this.playerResponseBytes(videoHTML)

0 commit comments

Comments
 (0)