blive-message-listener icon indicating copy to clipboard operation
blive-message-listener copied to clipboard

开始监听后立刻就关闭了

Open Nauxscript opened this issue 1 year ago • 10 comments

Describe the bug

const bilive = require('blive-message-listener');

bilive.startListen(5050, {
  onOpen() {
    console.log('open');
  },
  onClose() {
    console.log('close');
    process.exit()
  },
  onIncomeDanmu: (msg) => {
    console.log(msg.id, msg.body);
  },
});

运行后立刻就关闭了。

Reproduction

https://stackblitz.com/edit/stackblitz-starters-d4vbxi?file=index.js

System Info

System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 280.48 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.7.6 - /opt/homebrew/bin/pnpm
    bun: 1.0.0 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 123.0.6312.87

Used Package Manager

pnpm

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [X] The provided reproduction is a minimal reproducible of the bug.

Nauxscript avatar Apr 03 '24 10:04 Nauxscript

看起来现在连接auth参数是必传了,可以传入 ws.key 试试

https://github.com/ddiu8081/blive-message-listener?tab=readme-ov-file#options

ddiu8081 avatar Apr 03 '24 10:04 ddiu8081

前一段时间还行,然后这两天又不行了,然后发现getDanmuInfo这个API的key字段变成了token image

blacktunes avatar Apr 07 '24 08:04 blacktunes

目前看getDanmuInfo抓到的token似乎确实连不上,可以抓直播间ws请求里第一个数据包里的 key 是能用的,不知道有没有其他获取key的方式

CleanShot 2024-04-10 at 13 13 03

ddiu8081 avatar Apr 10 '24 05:04 ddiu8081

目前看getDanmuInfo抓到的token似乎确实连不上,可以抓直播间ws请求里第一个数据包里的 key 是能用的,不知道有没有其他获取key的方式

CleanShot 2024-04-10 at 13 13 03

稍微测试了一下,getDanmuInfo现在要带上id参数,获取到的token跟直播间是绑定的

blacktunes avatar Apr 10 '24 17:04 blacktunes

同样的问题,现在F12查看控制台的ws消息是乱码,是加密了吗

msinwolc avatar Jun 04 '24 10:06 msinwolc

同样的问题,现在F12查看控制台的ws消息是乱码,是加密了吗

@msinwolc 看起来没有变化,依然可以从ws消息中拿到key

ScreenShot 2024-06-05 at 23 31 58@2x

ddiu8081 avatar Jun 05 '24 15:06 ddiu8081

同样的问题,现在F12查看控制台的ws消息是乱码,是加密了吗

@msinwolc 看起来没有变化,依然可以从ws消息中拿到key

ScreenShot 2024-06-05 at 23 31 58@2x

重新看了下,确实可以拿到了

msinwolc avatar Jun 06 '24 02:06 msinwolc

我这边试了下 getDanmuInfo 拿到的 token 当作ws option的key的话是连不上的,另外一个 https://api.live.bilibili.com/room/v1/Danmu/getConf?room_id=? 返回的 token 也是连不上,不知道前面的大佬是怎么成功的,或者说还有其他获取key的地方吗

msinwolc avatar Jun 06 '24 07:06 msinwolc

我这边试了下 getDanmuInfo 拿到的 token 当作ws option的key的话是连不上的,另外一个 https://api.live.bilibili.com/room/v1/Danmu/getConf?room_id=? 返回的 token 也是连不上,不知道前面的大佬是怎么成功的,或者说还有其他获取key的地方吗

https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id=<roomID>获取到的token字段就是key

key跟登录账号的uid房间号对应,每个直播间的key都不一样,对不上的话链接就会直接关闭

{
    ws: {
      // 必须
      uid: 登录的账号UID,
      key: getDanmuInfo的token字段,
      // 不填也能用,暂时不知道有没有影响
      buvid: getDanmuInfo的cookie里的buvid3
    }
  }

不登录也能用,uid填0就行,但是会丢弹幕

blacktunes avatar Jun 06 '24 07:06 blacktunes

我这边试了下 getDanmuInfo 拿到的 token 当作ws option的key的话是连不上的,另外一个 https://api.live.bilibili.com/room/v1/Danmu/getConf?room_id=? 返回的 token 也是连不上,不知道前面的大佬是怎么成功的,或者说还有其他获取key的地方吗

https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id=<roomID>获取到的token字段就是key

key跟登录账号的uid房间号对应,每个直播间的key都不一样,对不上的话链接就会直接关闭

{
    ws: {
      // 必须
      uid: 登录的账号UID,
      key: getDanmuInfo的token字段,
      // 不填也能用,暂时不知道有没有影响
      buvid: getDanmuInfo的cookie里的buvid3
    }
  }

不登录也能用,uid填0就行,但是会丢弹幕

原来如此,我是未登录直接请求的 getDanmuInfo 但是uid填了我自己的uid,所以才会失败,把uid设置为0后就连接上了,感谢大佬指正

msinwolc avatar Jun 06 '24 08:06 msinwolc