This commit is contained in:
aynakeya
2025-10-14 23:57:44 +08:00
parent 5a0609edf4
commit 79ce0bb3c1

View File

@@ -11,7 +11,7 @@ import (
// RoomInfo // RoomInfo
// api https://api.live.bilibili.com/room/v1/Room/room_init?id={} response // api https://api.live.bilibili.com/room/v1/Room/room_init?id={} response
type RoomInfo struct { type RoomInitInfo struct {
Code int `json:"code"` Code int `json:"code"`
Msg string `json:"msg"` Msg string `json:"msg"`
Message string `json:"message"` Message string `json:"message"`
@@ -35,6 +35,81 @@ type RoomInfo struct {
} `json:"data"` } `json:"data"`
} }
// RoomInitInfo
// https://api.live.bilibili.com/room/v1/Room/get_info?id={} response
type RoomInfo struct {
Code int `json:"code"`
Msg string `json:"msg"`
Message string `json:"message"`
Data struct {
Uid int `json:"uid"`
RoomId int `json:"room_id"`
ShortId int `json:"short_id"`
Attention int `json:"attention"`
Online int `json:"online"`
IsPortrait bool `json:"is_portrait"`
Description string `json:"description"`
LiveStatus int `json:"live_status"`
AreaId int `json:"area_id"`
ParentAreaId int `json:"parent_area_id"`
ParentAreaName string `json:"parent_area_name"`
OldAreaId int `json:"old_area_id"`
Background string `json:"background"`
Title string `json:"title"`
UserCover string `json:"user_cover"`
Keyframe string `json:"keyframe"`
IsStrictRoom bool `json:"is_strict_room"`
LiveTime string `json:"live_time"`
Tags string `json:"tags"`
IsAnchor int `json:"is_anchor"`
RoomSilentType string `json:"room_silent_type"`
RoomSilentLevel int `json:"room_silent_level"`
RoomSilentSecond int `json:"room_silent_second"`
AreaName string `json:"area_name"`
Pendants string `json:"pendants"`
AreaPendants string `json:"area_pendants"`
HotWords []string `json:"hot_words"`
HotWordsStatus int `json:"hot_words_status"`
Verify string `json:"verify"`
NewPendants struct {
Frame struct {
Name string `json:"name"`
Value string `json:"value"`
Position int `json:"position"`
Desc string `json:"desc"`
Area int `json:"area"`
AreaOld int `json:"area_old"`
BgColor string `json:"bg_color"`
BgPic string `json:"bg_pic"`
UseOldArea bool `json:"use_old_area"`
} `json:"frame"`
Badge interface{} `json:"badge"`
MobileFrame struct {
Name string `json:"name"`
Value string `json:"value"`
Position int `json:"position"`
Desc string `json:"desc"`
Area int `json:"area"`
AreaOld int `json:"area_old"`
BgColor string `json:"bg_color"`
BgPic string `json:"bg_pic"`
UseOldArea bool `json:"use_old_area"`
} `json:"mobile_frame"`
MobileBadge interface{} `json:"mobile_badge"`
} `json:"new_pendants"`
UpSession string `json:"up_session"`
PkStatus int `json:"pk_status"`
PkId int `json:"pk_id"`
BattleId int `json:"battle_id"`
AllowChangeAreaTime int `json:"allow_change_area_time"`
AllowUploadCoverTime int `json:"allow_upload_cover_time"`
StudioInfo struct {
Status int `json:"status"`
MasterList []interface{} `json:"master_list"`
} `json:"studio_info"`
} `json:"data"`
}
// DanmuInfo // DanmuInfo
// api https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id={}&type=0 response // api https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id={}&type=0 response
type DanmuInfo struct { type DanmuInfo struct {
@@ -94,7 +169,7 @@ func GetRoomInfo(roomID int) (*RoomInfo, error) {
result := &RoomInfo{} result := &RoomInfo{}
headers := &http.Header{} headers := &http.Header{}
headers.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0") headers.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0")
err := GetJsonWithHeader(fmt.Sprintf("https://api.live.bilibili.com/room/v1/Room/room_init?id=%d", roomID), headers, result) err := GetJsonWithHeader(fmt.Sprintf("https://api.live.bilibili.com/room/v1/Room/get_info?id=%d", roomID), headers, result)
if err != nil { if err != nil {
return nil, err return nil, err
} }