spider

package
v0.0.0-...-30bf5e9 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WS_OP_HEARTBEAT                          = 2  //心跳
	WS_OP_HEARTBEAT_REPLY                    = 3  //心跳回应
	WS_OP_MESSAGE                            = 5  //弹幕消息等
	WS_OP_USER_AUTHENTICATION                = 7  //用户进入房间
	WS_OP_CONNECT_SUCCESS                    = 8  //进房回应
	WS_PACKAGE_HEADER_TOTAL_LENGTH           = 16 //头部字节大小
	WS_PACKAGE_OFFSET                        = 0
	WS_HEADER_OFFSET                         = 4
	WS_VERSION_OFFSET                        = 6
	WS_OPERATION_OFFSET                      = 8
	WS_SEQUENCE_OFFSET                       = 12
	WS_BODY_PROTOCOL_VERSION_NORMAL          = 0 //普通消息
	WS_BODY_PROTOCOL_VERSION_HEARTBEAT_REPLY = 1
	WS_BODY_PROTOCOL_VERSION_DEFLATE         = 2
	WS_BODY_PROTOCOL_VERSION_BROTLI          = 3 //brotli压缩信息
	WS_HEADER_DEFAULT_VERSION                = 1
	WS_HEADER_DEFAULT_OPERATION              = 1
	WS_HEADER_DEFAULT_SEQUENCE               = 1
	WS_AUTH_OK                               = 0
	WS_AUTH_TOKEN_ERROR                      = -101
)

from https://github.com/lovelyyoshino/Bilibili-Live-API/blob/master/API.WebSocket.md

View Source
const (
	Protover = 2
	Platform = "web"
	Type     = 2
)

from player-loader-2.0.11.min.js

customAuthParam

Variables

Functions

func Btoi16

func Btoi16(b []byte, offset int) int16

func Btoi32

func Btoi32(b []byte, offset int) int32

func EncodeMessage

func EncodeMessage(msg string, Operation int) []byte

func GetDanmuInfoURL

func GetDanmuInfoURL(roomID int) string

func GetInfoByRoomURL

func GetInfoByRoomURL(shortID int) string

func HelloGen

func HelloGen(roomid int, key string) []byte

认证生成与检查

func Init

func Init()

func Itob16

func Itob16(num int16) []byte

func Itob32

func Itob32(num int32) []byte

整数 字节转换区 32 4字节 16 2字节

Types

type DanmuSpider

type DanmuSpider struct {
	ShortID int

	Live              []string  //直播流链接
	Live_qn           int       //当前直播流质量
	Live_want_qn      int       //期望直播流质量
	RoomID            int       //房间id
	Title             string    //直播标题
	Uname             string    //主播名
	UpUid             int       //主播uid
	Rev               float64   //营收
	Renqi             int       //人气
	GuardNum          int       //舰长数
	ParentAreaID      int       //父分区
	AreaID            int       //子分区
	Locked            bool      //直播间封禁
	Note              string    //分区排行
	Live_Start_Time   time.Time //直播开始时间
	Liveing           bool      //是否在直播
	Wearing_FansMedal int       //当前佩戴的粉丝牌
	Token             string    //弹幕钥
	WSURL             []string  //弹幕链接
	LIVE_BUVID        bool      //cookies含LIVE_BUVID

	Dial *websocket.Conn
}

func NewDanmuSpider

func NewDanmuSpider(shortId int) *DanmuSpider

func (*DanmuSpider) DecodeMessage

func (d *DanmuSpider) DecodeMessage(msg []byte)

func (*DanmuSpider) HeartBeat

func (d *DanmuSpider) HeartBeat()

func (*DanmuSpider) Init

func (d *DanmuSpider) Init()

func (*DanmuSpider) MessageHandler

func (d *DanmuSpider) MessageHandler(msg *Message)

func (*DanmuSpider) Send

func (d *DanmuSpider) Send(msg []byte)

type Message

type Message struct {
	PacketLen int32
	HeaderLen int16
	Ver       int16
	Op        int32
	Seq       int32
	Body      []byte
}

type WsServer

type WsServer struct {
	// contains filtered or unexported fields
}

func NewWsServer

func NewWsServer() *WsServer

Jump to

Keyboard shortcuts

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