Skip to content

Commit

Permalink
✨ feat(commClient): LiveGetMedalRank
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Nov 6, 2021
1 parent 927fc5a commit 196b042
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
23 changes: 23 additions & 0 deletions comm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 10 additions & 0 deletions comm_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
22 changes: 22 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 196b042

Please sign in to comment.