api

package
v0.0.0-...-cc4a4ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJson

func GetJson(url string, result interface{}) error

func GetJsonWithHeader

func GetJsonWithHeader(url string, headers *http.Header, result interface{}) error

func GetRoomRealID

func GetRoomRealID(roomID int) (string, error)

func GetUid

func GetUid(cookie string) (int, error)

func HttpGet

func HttpGet(url string, headers *http.Header) ([]byte, error)

func WbiKeysSign

func WbiKeysSign(u *url.URL) error

Sign 为链接签名

func WbiKeysSignString

func WbiKeysSignString(u string) (string, error)

func WbiKeysUpdate

func WbiKeysUpdate() error

Update 无视过期时间更新

Types

type BiliVerify

type BiliVerify struct {
	Csrf     string
	SessData string
}

type DanmakuRequest

type DanmakuRequest struct {
	Msg      string
	RoomID   string
	Bubble   string
	Color    string
	FontSize string
	Mode     string
	DmType   string
}

type DanmuInfo

type DanmuInfo struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Ttl     int    `json:"ttl"`
	Data    struct {
		Group            string  `json:"group"`
		BusinessId       int     `json:"business_id"`
		RefreshRowFactor float64 `json:"refresh_row_factor"`
		RefreshRate      int     `json:"refresh_rate"`
		MaxDelay         int     `json:"max_delay"`
		Token            string  `json:"token"`
		HostList         []struct {
			Host    string `json:"host"`
			Port    int    `json:"port"`
			WssPort int    `json:"wss_port"`
			WsPort  int    `json:"ws_port"`
		} `json:"host_list"`
	} `json:"data"`
}

DanmuInfo api https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id={}&type=0 response

func GetDanmuInfo

func GetDanmuInfo(roomID int, cookie string) (*DanmuInfo, error)

type IApi

type IApi interface {
	GetDanmuInfo(roomID int) (int, *DanmuInfo, error)
	GetRoomInfo(roomID int) (*RoomInfo, error)
}

func NewDefaultClient

func NewDefaultClient(cookie string) IApi
type Nav struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Ttl     int    `json:"ttl"`
	Data    struct {
		WbiImg struct {
			ImgUrl string `json:"img_url"`
			SubUrl string `json:"sub_url"`
		} `json:"wbi_img"`
	} `json:"data"`
}

type RoomInfo

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"`
}

RoomInitInfo https://api.live.bilibili.com/room/v1/Room/get_info?id={} response

func GetRoomInfo

func GetRoomInfo(roomID int) (*RoomInfo, error)

type RoomInitInfo

type RoomInitInfo struct {
	Code    int    `json:"code"`
	Msg     string `json:"msg"`
	Message string `json:"message"`
	Data    struct {
		RoomId      int   `json:"room_id"`
		ShortId     int   `json:"short_id"`
		Uid         int   `json:"uid"`
		NeedP2P     int   `json:"need_p2p"`
		IsHidden    bool  `json:"is_hidden"`
		IsLocked    bool  `json:"is_locked"`
		IsPortrait  bool  `json:"is_portrait"`
		LiveStatus  int   `json:"live_status"`
		HiddenTill  int   `json:"hidden_till"`
		LockTill    int   `json:"lock_till"`
		Encrypted   bool  `json:"encrypted"`
		PwdVerified bool  `json:"pwd_verified"`
		LiveTime    int64 `json:"live_time"`
		RoomShield  int   `json:"room_shield"`
		IsSp        int   `json:"is_sp"`
		SpecialType int   `json:"special_type"`
	} `json:"data"`
}

RoomInfo api https://api.live.bilibili.com/room/v1/Room/room_init?id={} response

type SendDanmakuResp

type SendDanmakuResp struct {
	Code int `json:"code"`
	Data struct {
		ModeInfo struct {
			Mode           int    `json:"mode"`
			ShowPlayerType int    `json:"show_player_type"`
			Extra          string `json:"extra"`
		} `json:"mode_info"`
	} `json:"data"`
	Message string `json:"message"`
	Msg     string `json:"msg"`
}

func SendDefaultDanmaku

func SendDefaultDanmaku(roomID string, message string, verify *BiliVerify) (*SendDanmakuResp, error)

type WbiKeys

type WbiKeys struct {
	Img   string
	Sub   string
	Mixin string
	// contains filtered or unexported fields
}

func WbiKeysGet

func WbiKeysGet() (wk WbiKeys, err error)

func (*WbiKeys) Sign

func (wk *WbiKeys) Sign(u *url.URL) (err error)

Sign 为链接签名

func (*WbiKeys) Update

func (wk *WbiKeys) Update() (err error)

Update 无视过期时间更新

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL