diff --git a/comm_client.go b/comm_client.go index 361dd07..c268e12 100644 --- a/comm_client.go +++ b/comm_client.go @@ -1191,3 +1191,26 @@ func (c *CommClient) LiveGetGuardList(roomID int64, mid int64, pn int, ps int) ( } return r, nil } + +// LiveGetMedalRank 获取直播间粉丝勋章榜 +// +// mid: 主播mid +func (c *CommClient) LiveGetMedalRank(roomID int64, mid int64) (*LiveMedalRank, error) { + resp, err := c.RawParse( + BiliLiveURL, + "rankdb/v1/RoomRank/webMedalRank", + "GET", + map[string]string{ + "roomid": strconv.FormatInt(roomID, 10), + "ruid": strconv.FormatInt(mid, 10), + }, + ) + if err != nil { + return nil, err + } + var r = &LiveMedalRank{} + if err = json.Unmarshal(resp.Data, &r); err != nil { + return nil, err + } + return r, nil +} diff --git a/comm_client_test.go b/comm_client_test.go index 31e2da7..e8f4187 100644 --- a/comm_client_test.go +++ b/comm_client_test.go @@ -536,3 +536,13 @@ func TestCommClient_LiveGetGuardList(t *testing.T) { t.Logf("\tuid: %d,uname: %s,rank: %d,level: %d", l.UID, l.Username, l.Rank, l.GuardLevel) } } +func TestCommClient_LiveGetMedalRank(t *testing.T) { + r, err := testCommClient.LiveGetMedalRank(545068, 8739477) + if err != nil { + t.Error(err) + t.FailNow() + } + for _, l := range r.List { + t.Logf("rank: %d,uname: %s,medal: %s,guard: %d,level: %d", l.Rank, l.Uname, l.MedalName, l.GuardLevel, l.Level) + } +} diff --git a/types.go b/types.go index 95806d5..989459f 100644 --- a/types.go +++ b/types.go @@ -1537,3 +1537,25 @@ type LiveGuardList struct { GuardSubLevel int `json:"guard_sub_level"` } `json:"top3"` } +type LiveMedalRank struct { + Medal struct { + Status int `json:"status"` + } `json:"medal"` + List []*struct { + UID int64 `json:"uid"` // mid + Uname string `json:"uname"` // 昵称 + Face string `json:"face"` // 头像url + Rank int `json:"rank"` // 排名 + MedalName string `json:"medal_name"` // 勋章名字 + Level int `json:"level"` // 勋章等级 + Color int64 `json:"color"` // 勋章颜色 + TargetID int64 `json:"target_id"` // 主播mid + Special string `json:"special"` + IsSelf int `json:"isSelf"` + GuardLevel int `json:"guard_level"` // 1:总督 2:提督 3:舰长 + MedalColorStart int64 `json:"medal_color_start"` + MedalColorEnd int64 `json:"medal_color_end"` + MedalColorBorder int64 `json:"medal_color_border"` + IsLighted int `json:"is_lighted"` + } `json:"list"` +}