Skip to content

Commit

Permalink
♻️ refactor(commClient): LiveGetRoomInfoByMID
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Nov 13, 2021
1 parent 4ac2ea4 commit a0c023d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
17 changes: 2 additions & 15 deletions comm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,24 +1079,11 @@ func (c *CommClient) ChargeVideoGetList(mid int64, aid int64) (*ChargeVideoList,
//
// 从mid获取直播间信息
func (c *CommClient) LiveGetRoomInfoByMID(mid int64) (*LiveRoomInfoByMID, error) {
resp, err := c.RawParse(
BiliApiURL,
"x/space/acc/info",
"GET",
map[string]string{
"mid": strconv.FormatInt(mid, 10),
},
)
r, err := c.UserGetInfo(mid)
if err != nil {
return nil, err
}
var info struct {
LiveRoom *LiveRoomInfoByMID `json:"live_room"`
}
if err = json.Unmarshal(resp.Data, &info); err != nil {
return nil, err
}
return info.LiveRoom, nil
return (*LiveRoomInfoByMID)(&r.LiveRoom), nil
}

// LiveGetRoomInfoByID 从roomID获取直播间信息
Expand Down
2 changes: 1 addition & 1 deletion comm_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func TestCommClient_ChargeVideoList(t *testing.T) {
t.Logf("\tmid: %d,rank: %d,uname: %s,msg: %s", i.PayMID, i.Rank, i.Uname, i.Message)
}
}
func TestCommClient_LiveRoomInfo(t *testing.T) {
func TestCommClient_LiveGetRoomInfoByMID(t *testing.T) {
info, err := testCommClient.LiveGetRoomInfoByMID(436473455)
if err != nil {
t.Error(err)
Expand Down

0 comments on commit a0c023d

Please sign in to comment.