diff options
author | Keuin <[email protected]> | 2023-07-11 22:56:07 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-07-11 22:56:07 +0800 |
commit | f5c63cde56eb35c0125a0545f084441cdd4340ab (patch) | |
tree | cf24779daaa3067902bef91d21bcdee7a78fd059 /bilibili/room_status.go | |
parent | 7fd817f6d1ead3de85294c1893a6e1572a1d12e3 (diff) |
Refactor: move data structures to a separate package to avoid circular dependency.
Diffstat (limited to 'bilibili/room_status.go')
-rw-r--r-- | bilibili/room_status.go | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/bilibili/room_status.go b/bilibili/room_status.go index cbb8bc4..f33277c 100644 --- a/bilibili/room_status.go +++ b/bilibili/room_status.go @@ -6,52 +6,11 @@ package bilibili import ( "fmt" + "github.com/keuin/slbr/types" ) -type LiveStatus int - -const ( - Inactive LiveStatus = 0 - Streaming LiveStatus = 1 - Playback LiveStatus = 2 -) - -var liveStatusStringMap = map[LiveStatus]string{ - Inactive: "inactive", - Streaming: "streaming", - Playback: "inactive (playback)", -} - -type roomPlayInfo struct { - RoomID uint64 `json:"room_id"` - ShortID uint `json:"short_id"` - UID uint `json:"uid"` - IsHidden bool `json:"is_hidden"` - IsLocked bool `json:"is_locked"` - IsPortrait bool `json:"is_portrait"` - LiveStatus LiveStatus `json:"live_status"` // 0: inactive 1: streaming 2: playback - HiddenTill int `json:"hidden_till"` - LockTill int `json:"lock_till"` - Encrypted bool `json:"encrypted"` - PwdVerified bool `json:"pwd_verified"` - LiveTime int `json:"live_time"` - RoomShield int `json:"room_shield"` - AllSpecialTypes []interface{} `json:"all_special_types"` - PlayurlInfo interface{} `json:"playurl_info"` -} - -type RoomPlayInfoResponse = BaseResponse[roomPlayInfo] - -func (s LiveStatus) IsStreaming() bool { - return s == Streaming -} - -func (s LiveStatus) String() string { - return liveStatusStringMap[s] -} - -func (b Bilibili) GetRoomPlayInfo(roomId RoomId) (resp RoomPlayInfoResponse, err error) { +func (b Bilibili) GetRoomPlayInfo(roomId types.RoomId) (resp types.RoomPlayInfoResponse, err error) { url := fmt.Sprintf("https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo"+ "?room_id=%d&protocol=0,1&format=0,1,2&codec=0,1&qn=0&platform=web&ptype=8&dolby=5&panorama=1", roomId) - return callGet[RoomPlayInfoResponse](b, url) + return callGet[types.RoomPlayInfoResponse](b, url) } |