更新B站的api接口
This commit is contained in:
parent
7a5475b93c
commit
c066a5a8c4
@ -32,19 +32,21 @@ export class DanmakuReceiver extends EventEmitter {
|
|||||||
}
|
}
|
||||||
public async connect() {
|
public async connect() {
|
||||||
const roomConfig = await (await fetch(
|
const roomConfig = await (await fetch(
|
||||||
`https://api.live.bilibili.com/room/v1/Danmu/getConf?room_id=${this.roomId}&platform=pc&player=web`,
|
`https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id=${this.roomId}&type=0`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
cookie,
|
Cookie: cookie,
|
||||||
"user-agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (X11 Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
|
"Mozilla/5.0 (X11 Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
|
||||||
host: "api.live.bilibili.com",
|
Host: "api.live.bilibili.com",
|
||||||
|
Origin: 'https://live.bilibili.com',
|
||||||
|
Referer: `https://live.bilibili.com/${this.roomId}?broadcast_type=0`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)).json()
|
)).json()
|
||||||
this.ws = new WebSocket(
|
this.ws = new WebSocket(
|
||||||
`wss://${roomConfig.data.host_server_list[0].host}:${
|
`wss://${roomConfig.data.host_list[0].host}:${
|
||||||
roomConfig.data.host_server_list[0].wss_port
|
roomConfig.data.host_list[0].wss_port
|
||||||
}/sub`,
|
}/sub`,
|
||||||
)
|
)
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
@ -54,6 +56,7 @@ export class DanmakuReceiver extends EventEmitter {
|
|||||||
platform: "web",
|
platform: "web",
|
||||||
uid: config.verify.uid,
|
uid: config.verify.uid,
|
||||||
key: roomConfig.data.token,
|
key: roomConfig.data.token,
|
||||||
|
type: 2
|
||||||
})
|
})
|
||||||
this.ws!.send(this.generatePacket(
|
this.ws!.send(this.generatePacket(
|
||||||
1,
|
1,
|
||||||
|
@ -22,7 +22,10 @@ if (!config.disable_super_chat_action) {
|
|||||||
globalThis.onunload = () => {
|
globalThis.onunload = () => {
|
||||||
printLog('主程序', '退出')
|
printLog('主程序', '退出')
|
||||||
}
|
}
|
||||||
danmakuReceiver.on('closed', () => danmakuReceiver.connect())
|
danmakuReceiver.on('closed', () => {
|
||||||
|
printLog('主程序', '掉线了')
|
||||||
|
danmakuReceiver.connect()
|
||||||
|
})
|
||||||
danmakuReceiver.on('LIVE', onLiveStart)
|
danmakuReceiver.on('LIVE', onLiveStart)
|
||||||
danmakuReceiver.on('PREPARING', onLiveEnd)
|
danmakuReceiver.on('PREPARING', onLiveEnd)
|
||||||
danmakuReceiver.on('DANMU_MSG', receiveDanmaku)
|
danmakuReceiver.on('DANMU_MSG', receiveDanmaku)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user