blive

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 10 Imported by: 0

README

blive-go

bilibili api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BUser

type BUser struct {
	UID   int64  // 用户 ID,阿b 啊,你的 id 怎么算的啦,还逼我用 int64 [哭]
	BUVID string // 和 uid 一样是至关重要的参数
	// contains filtered or unexported fields
}

BUser 用户

模拟一个用户看似正常的行为。嘘!偷偷的,来和阿b 捉迷藏~

func NewUser

func NewUser() *BUser

NewUser 创建一个用户

func (*BUser) Close

func (u *BUser) Close()

Close 关闭 websocket 连接

func (*BUser) DecodePackage

func (u *BUser) DecodePackage(v []byte) (DanmuType, [][]byte)

DecodePackage 解包

func (*BUser) Enter

func (u *BUser) Enter(urlStr string) error

Enter 进入直播间

func (*BUser) GetAuthPackage

func (u *BUser) GetAuthPackage(mid int, token string) []byte

GetAuthPackage 获取认证包

func (*BUser) GetBuvid

func (u *BUser) GetBuvid() error

GetBuvid 获取 buvid3

func (*BUser) GetDanmuInfo

func (u *BUser) GetDanmuInfo(room_id int) (*DanmuInfoData, error)

GetDanmuInfo 获取弹幕服务器信息

func (*BUser) GetHeartPackage

func (u *BUser) GetHeartPackage() []byte

GetHeartPackage 获取心跳包

func (*BUser) GetRoomInfo

func (u *BUser) GetRoomInfo(room_id int) (*RoomInfoData, error)

GetRoomInfo 获取直播间信息

func (*BUser) GetUserInfo

func (u *BUser) GetUserInfo() (*UserInfoData, error)

GetUserInfo 获取导航栏用户信息

func (*BUser) GetVideoUrl

func (u *BUser) GetVideoUrl(mid int) (*VideData, error)

GetVideoUrl 获取直播视频流

func (*BUser) Listen

func (u *BUser) Listen(v chan []byte)

Listen 监听 websocket 数据

func (*BUser) QRCodeGenerate

func (u *BUser) QRCodeGenerate() (*QRCodeGenerateData, error)

QRCodeGenerate 申请登录二维码

二维码失效时间为 180 秒

func (*BUser) QRCodePoll

func (u *BUser) QRCodePoll(qrcode_key string) (*QRCodePollData, error)

QRCodePoll 检查二维码登录状态

轮询间隔不应该低于 1 秒

func (*BUser) SetCookieString

func (u *BUser) SetCookieString(cookie string)

SetCookieString 设置 Cookie 字符串

func (*BUser) SetUserInfo

func (u *BUser) SetUserInfo() error

SetUserInfo 设置用户信息

func (*BUser) Write

func (u *BUser) Write(v []byte) error

Write 写 websocket 数据

type DanmuInfoData

type DanmuInfoData struct {
	Group            string  `json:"group"`
	BusinessID       int     `json:"business_id"`
	RefreshRowFactor float32 `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"`     // tcp 端口
		WSSPort int    `json:"wss_port"` // wss 端口
		WSPort  int    `json:"ws_port"`  // ws 端口
	} `json:"host_list"`
}

type DanmuType

type DanmuType int
const (
	DanmuHeart  DanmuType = iota // 心跳回复包
	DanmuAuth                    // 认证回复包
	DanmuCommon                  // 普通未压缩包
	DanmuZlib                    // zlib 压缩包
	DanmuBrotli                  // brotli 压缩包
	DanmuUnknow                  // 未知类型
)

type OfficalRole

type OfficalRole int

OfficalRole 用户认证类型

const (
	RoleNil                   OfficalRole = 0 // 无认证
	RoleKnownUP               OfficalRole = 1 // 知名UP主
	RoleBigV                  OfficalRole = 2 // 大V达人
	RoleEnterprise            OfficalRole = 3 // 企业
	RoleOrganization          OfficalRole = 4 // 组织
	RoleMedia                 OfficalRole = 5 // 媒体
	RoleGovernment            OfficalRole = 6 // 政府
	RoleHighEnergyBroadcaster OfficalRole = 7 // 高能主播
	RoleSocialCelebrity       OfficalRole = 8 // 社会知名人士
)

func (OfficalRole) String

func (r OfficalRole) String() string

String 打印认证类型

type QRCodeGenerateData

type QRCodeGenerateData struct {
	Url       string `json:"url"`        // 二维码内容(登录页面url)
	QRCodeKey string `json:"qrcode_key"` // 扫码登录密钥
}

type QRCodePollData

type QRCodePollData struct {
	Url          string       `json:"url"`           // 游戏分站跨域登录url
	RefreshToken string       `json:"refresh_token"` // 刷新 refresh_token
	Timestamp    int64        `json:"timestamp"`     // 登录时间,毫秒级
	Code         QRCodeStatus `json:"code"`          // 登录状态
	Message      string       `json:"message"`       // 扫码状态信息
}

type QRCodeStatus

type QRCodeStatus int

QRCodeStatus 扫码状态

const (
	ScanWaiting   QRCodeStatus = 86101 // 二维码未扫描
	ConfirmWating QRCodeStatus = 86090 // 等待手机确认
	Confirmed     QRCodeStatus = 0     // 登录成功
	Timeout       QRCodeStatus = 86038 // 二维码失效
)

func (QRCodeStatus) String

func (s QRCodeStatus) String() string

String 打印二维码状态

type RoomInfoData

type RoomInfoData struct {
	UID              int64    `json:"uid"`                // 主播mid
	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"`        // 直播状态 0: 未开播 1: 直播中 2: 轮播中
	AreaID           int      `json:"area_id"`            // 分区ID
	ParentAreaID     int      `json:"parent_area_id"`     // 父分区ID
	ParentAreaName   string   `json:"parent_area_name"`   // 父分区名称
	OldAreaID        int      `json:"old_area_id"`        // 旧版分区ID
	Background       string   `json:"background"`         // 背景图片链接
	Title            string   `json:"title"`              // 标题
	UserCover        string   `json:"user_cover"`         // 封面
	LiveTime         string   `json:"live_time"`          // 直播开始时间 YYYY-MM-DD HH:mm:ss
	Tags             string   `json:"tags"`               // 标签 ;分隔
	RoomSilentType   string   `json:"room_silent_type"`   // 禁言状态
	RoomSilentLevel  int      `json:"room_silent_level"`  // 禁言等级
	RoomSilentSecond int      `json:"room_silent_second"` // 禁言时间 单位是秒
	AreaName         string   `json:"area_name"`          // 分区名称
	HotWords         []string `json:"hot_words"`          // 热词
	HotWordsStatus   int      `json:"hot_words_status"`   // 热词状态
	PKStatus         int      `json:"pk_status"`          // PK 状态
	PKID             int      `json:"pk_id"`              // PK ID
}

type UserInfoData

type UserInfoData struct {
	IsLogin       bool   `json:"isLogin"`        // 是否已登录
	EmailVerified int    `json:"email_verified"` // 是否验证邮箱地址 0: 未验证 1: 已验证
	Face          string `json:"face"`           // 用户头像 url
	LevelInfo     struct {
		CurrentLevel int `json:"current_level"` // 当前等级
		CurrentMin   int `json:"current_min"`   // 当前等级经验最低值
		CurrentExp   int `json:"current_exp"`   // 当前经验
		NextExp      any `json:"next_exp"`      // 下一级所需经验,小于6级是num,等于6级是str(--)
	} `json:"level_info"` // 等级信息
	Mid            int64 `json:"mid"`             // 用户mid
	MobileVerified int   `json:"mobile_verified"` // 是否验证手机号 0: 未验证 1: 已验证
	Money          int   `json:"money"`           // 拥有硬币数
	Moral          int   `json:"moral"`           // 当前节操值 上限为70
	Offical        struct {
		Role  OfficalRole `json:"role"`  // 认证类型
		Title string      `json:"title"` // 认证信息
		Desc  string      `json:"desc"`  // 认证备注
		Type  int         `json:"type"`  // 是否认证 -1: 无 0: 认证
	} `json:"offical"` // 认证信息
	OfficalVerify struct {
		Type int    `json:"type"` // 是否认证 -1: 无 0: 认证
		Desc string `json:"desc"` // 认证信息
	} `json:"officialVerify"` // 认证信息
	Pendant struct {
		Pid    int    `json:"pid"`    // 挂件 ID
		Name   string `json:"name"`   // 挂件名称
		Image  string `json:"image"`  // 挂件图像url
		Expire int    `json:"expire"` // Unknown
	} `json:"pendant"` // 头像框信息
	Scores       int    `json:"scores"`         // Unknown
	Uname        string `json:"uname"`          // 用户昵称
	VipDueDate   int64  `json:"vipDueDate"`     // 会员到期时间 毫秒
	VipStatus    int    `json:"vipStatus"`      // 会员开通状态 0: 无 1: 有
	VipType      int    `json:"vipType"`        // 会员类型 0: 无 1: 月度大会员 2: 年度及以上大会员
	VipPayType   int    `json:"vip_pay_type"`   // 会员开通状态 0: 无 1: 有
	VipThemeType int    `json:"vip_theme_type"` // Unknown
	VipLabel     struct {
		Path       string `json:"path"`        // Unknown
		Text       string `json:"text"`        // 会员名称
		LabelTheme string `json:"label_theme"` // vip: 大会员 annual_vip: 年度大会员 ten_annual_vip: 十年大会员 hundred_annual_vip: 百年大会员
	} `json:"vip_label"` // 会员标签
	VipAvatarSubscript int    `json:"vip_avatar_subscript"` // 是否显示会员图标 0: 不显示 1: 显示
	VipNicknameColor   string `json:"vip_nickname_color"`   // 颜色码
	Wallet             struct {
		Mid           int64   `json:"mid"`
		BCoinBalance  float32 `json:"bcoin_balance"`   // 拥有B币数
		CouponBalance int     `json:"coupon_balance"`  // 每月奖励B币数
		CouponDueTime int     `json:"coupon_due_time"` // Unknown
	} `json:"wallet"`
	HasShop        bool `json:"has_shop"`         // 是否拥有推广商品
	IsSeniorMember int  `json:"is_senior_member"` // 是否硬核会员 0: 非硬核会员 1: 硬核会员
	IsJury         bool `json:"is_jury"`          // 是否是风纪委员
}

type VideData

type VideData struct {
	CurrentQuality     int      `json:"current_quality"` // 当前画质代码
	AcceptQuality      []string `json:"accept_quality"`  // 可选画质参数
	CurrentQN          int      `json:"current_qn"`      // 当前画质代码
	QualityDescription []struct {
		QN   int    `json:"qn"`   // 画质代码
		Desc string `json:"desc"` // 该代码对应的画质名称
	} `json:"quality_description"` // 可选画质参数
	DUrl []struct {
		Url        string `json:"url"`         // flv 或 m3u8 格式 带有转义
		Length     int    `json:"length"`      // Unknown
		Order      int    `json:"order"`       // 服务器线路序号
		StreamType int    `json:"stream_type"` // Unknown
		P2PType    int    `json:"p2p_type"`    // Unknown
	} `json:"durl"` // 直播流 url 组
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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