diff options
author | Keuin <[email protected]> | 2022-09-07 02:48:46 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-09-07 02:48:46 +0800 |
commit | 8e15d802865ed57db0018c15ea5559c8bd44c01f (patch) | |
tree | 48f4632a1ad044bd7f7f8da3ebe2bb03ab4ca6fe /bilibili/play_url.go | |
parent | 88234ca8fffc4e120adbe0d38071b625ad2f43c7 (diff) |
First working version. Just a POC.
Diffstat (limited to 'bilibili/play_url.go')
-rw-r--r-- | bilibili/play_url.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bilibili/play_url.go b/bilibili/play_url.go new file mode 100644 index 0000000..282d556 --- /dev/null +++ b/bilibili/play_url.go @@ -0,0 +1,35 @@ +package bilibili + +import ( + "bilibili-livestream-archiver/common" + "fmt" +) + +type RoomUrlInfoResponse = BaseResponse[roomUrlInfo] + +type roomUrlInfo struct { + CurrentQuality int `json:"current_quality"` + AcceptQuality []string `json:"accept_quality"` + CurrentQualityNumber int `json:"current_qn"` + QualityDescription []qualityDescription `json:"quality_description"` + URLs []StreamingUrlInfo `json:"durl"` +} + +type qualityDescription struct { + QualityNumber int `json:"qn"` + Description string `json:"desc"` +} + +type StreamingUrlInfo struct { + URL string `json:"url"` + Length int `json:"length"` + Order int `json:"order"` + StreamType int `json:"stream_type"` + P2pType int `json:"p2p_type"` +} + +func (b Bilibili) GetStreamingInfo(roomId common.RoomId) (resp RoomUrlInfoResponse, err error) { + url := fmt.Sprintf("https://api.live.bilibili.com/room/v1/Room/playUrl?"+ + "cid=%d&otype=json&qn=10000&platform=web", roomId) + return callGet[RoomUrlInfoResponse](b, url) +} |