diff options
author | Keuin <[email protected]> | 2023-07-12 00:19:34 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-07-12 00:19:34 +0800 |
commit | d7bd3edf61109936a09a5115938e86b1c17ea024 (patch) | |
tree | bdd8f97f960ff553df38322b58bf6fdb538e92d3 | |
parent | b22c11fef53a6e3dc138b06eb6bdc115c88e7e28 (diff) |
Refactor: move data structure from `danmaku_server_info.go` to `types`.refactor-common
-rw-r--r-- | bilibili/danmaku_server_info.go | 21 | ||||
-rw-r--r-- | types/live_room.go | 17 |
2 files changed, 19 insertions, 19 deletions
diff --git a/bilibili/danmaku_server_info.go b/bilibili/danmaku_server_info.go index 5df8ed7..e3cfbc0 100644 --- a/bilibili/danmaku_server_info.go +++ b/bilibili/danmaku_server_info.go @@ -5,24 +5,7 @@ import ( "github.com/keuin/slbr/types" ) -type DanmakuServerInfoResponse = types.BaseResponse[danmakuInfo] - -type danmakuInfo struct { - Group string `json:"group"` - BusinessID int `json:"business_id"` - RefreshRowFactor float64 `json:"refresh_row_factor"` - RefreshRate int `json:"refresh_rate"` - MaxDelay int `json:"max_delay"` - Token string `json:"token"` - HostList []struct { - Host string `json:"host"` - Port int `json:"port"` - WssPort int `json:"wss_port"` - WsPort int `json:"ws_port"` - } `json:"host_list"` -} - -func (b Bilibili) GetDanmakuServerInfo(roomId types.RoomId) (resp DanmakuServerInfoResponse, err error) { +func (b Bilibili) GetDanmakuServerInfo(roomId types.RoomId) (resp types.DanmakuServerInfoResponse, err error) { url := fmt.Sprintf("https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id=%d&type=0", roomId) - return callGet[DanmakuServerInfoResponse](b, url) + return callGet[types.DanmakuServerInfoResponse](b, url) } diff --git a/types/live_room.go b/types/live_room.go index 6d39ecb..77588c5 100644 --- a/types/live_room.go +++ b/types/live_room.go @@ -139,3 +139,20 @@ func (s LiveStatus) IsStreaming() bool { func (s LiveStatus) String() string { return liveStatusStringMap[s] } + +type DanmakuServerInfoResponse = BaseResponse[danmakuInfo] + +type danmakuInfo struct { + Group string `json:"group"` + BusinessID int `json:"business_id"` + RefreshRowFactor float64 `json:"refresh_row_factor"` + RefreshRate int `json:"refresh_rate"` + MaxDelay int `json:"max_delay"` + Token string `json:"token"` + HostList []struct { + Host string `json:"host"` + Port int `json:"port"` + WssPort int `json:"wss_port"` + WsPort int `json:"ws_port"` + } `json:"host_list"` +} |