summaryrefslogtreecommitdiff
path: root/bilibili
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-29 20:28:19 +0800
committerKeuin <[email protected]>2023-07-29 20:28:28 +0800
commitc4dbd4a7b2ad86fcb0220a4e2ffdae68d0d00103 (patch)
tree37e3487153a377aa5555d780c15f3a774237722e /bilibili
parent9b5c3913989754370bd7d03ac8cf2e32a6172afb (diff)
Merge branch 'bugfix-invalid-dmmsg'v0.5.0
Diffstat (limited to 'bilibili')
-rw-r--r--bilibili/connect.go2
-rw-r--r--bilibili/danmaku_server_info.go6
-rw-r--r--bilibili/request.go2
3 files changed, 4 insertions, 6 deletions
diff --git a/bilibili/connect.go b/bilibili/connect.go
index 472c979..de608d0 100644
--- a/bilibili/connect.go
+++ b/bilibili/connect.go
@@ -5,7 +5,7 @@ import (
"nhooyr.io/websocket"
)
-func (b Bilibili) DialWebSocket(ctx context.Context, url string) (*websocket.Conn, error) {
+func (b *Bilibili) DialWebSocket(ctx context.Context, url string) (*websocket.Conn, error) {
ws, _, err := websocket.Dial(ctx, url, &websocket.DialOptions{
HTTPClient: b.http,
})
diff --git a/bilibili/danmaku_server_info.go b/bilibili/danmaku_server_info.go
index 8c79d51..119a8f9 100644
--- a/bilibili/danmaku_server_info.go
+++ b/bilibili/danmaku_server_info.go
@@ -7,8 +7,6 @@ import (
"net/url"
)
-type WebBannerResponse = BaseResponse[interface{}]
-
const apiUrlPrefix = "https://api.live.bilibili.com"
func (b *Bilibili) GetDanmakuServerInfo(roomId types.RoomId) (resp types.DanmakuServerInfoResponse, err error) {
@@ -38,10 +36,10 @@ func (b *Bilibili) GetBUVID() (string, error) {
}
// GetLiveBUVID initializes cookie `LIVE_BUVID`. This should be called before GetDanmakuServerInfo.
-func (b *Bilibili) GetLiveBUVID(roomId types.RoomId) (resp WebBannerResponse, err error) {
+func (b *Bilibili) GetLiveBUVID(roomId types.RoomId) (resp types.WebBannerResponse, err error) {
u := fmt.Sprintf("https://api.live.bilibili.com/activity/v1/Common/webBanner?"+
"platform=web&position=6&roomid=%d&area_v2_parent_id=0&area_v2_id=0&from=", roomId)
- resp, err = callGet[WebBannerResponse](b, u)
+ resp, err = callGet[types.WebBannerResponse](b, u)
if err == nil {
uu, _ := url.Parse(apiUrlPrefix)
b.logger.Info("Cookie info: %v", b.http.Jar.Cookies(uu))
diff --git a/bilibili/request.go b/bilibili/request.go
index 613530c..39479a1 100644
--- a/bilibili/request.go
+++ b/bilibili/request.go
@@ -60,7 +60,7 @@ func callGetRaw(b *Bilibili, url string) (resp *http.Response, respBody []byte,
}
// callGet make a GET request and parse response as a JSON document with given model.
-func callGet[T BaseResponse[V], V any](b Bilibili, url string) (resp T, err error) {
+func callGet[T types.BaseResponse[V], V any](b *Bilibili, url string) (resp T, err error) {
r, data, err := callGetRaw(b, url)
if err != nil {
return