Giter Club home page Giter Club logo

bilibili-live-api's Introduction

Hello, I'm Ma Peili 👋 | 🏠个人博客:Hermit_Rabbit

GIF

🌱 I’m currently learning deep learning and SLAM on robotics;

💼 major in computer science and robotics;

👯 Ask me about gmail [email protected];

logo

bilibili-live-api's People

Contributors

dafrok avatar dfaofeng avatar ganlvtech avatar kooritea avatar lovelyyoshino avatar sdttttt avatar simon300000 avatar wetoria avatar zer0e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bilibili-live-api's Issues

关于直播区html5播放器的接口获取

emmm,兄台,如果你有空的话,能不能想办法查一下如何获取直播区的一些接口
比如直播区html5播放器的接口
原来还有部分是被flash调用的,暴露在window下
我粗略的查了下,现在貌似都打包进了工程里,没有再暴露出来
虽然我对着格式化的混淆代码找到了那些东西
但是想要用还是有点麻烦的,毕竟是混淆后的函数名,很容易变化
如果能够有一些办法确定几个接口就好了
比如发送弹幕之类的(不是网络请求接口,而是本地的播放器接口)
谢谢

弹幕WebSocket解析逻辑

API.WebSocket.md 里面

let body = textDecoder.decode(pako.inflate(data));
if (body) {
    // 同一条 message 中可能存在多条信息,用正则筛出来
    const group = body.split(/[\x00-\x1f]+/);
    group.forEach(item => {
      try {
        result.body.push(JSON.parse(item));
      }
      catch(e) {
        // 忽略非 JSON 字符串,通常情况下为分隔符
      }
    });
}

按照目前的弹幕数据,解析逻辑可以优化下

let body = '';
try {
    // pako可能无法解压
    body = textDecoder.decode(pako.inflate(data));
}
catch (e){
   body = textDecoder.decode(data)
}

if (body) {
    // 同一条 message 中可能存在多条信息,用正则筛出来
    const group = body.split(/[\x00-\x1f]+/);
    group.forEach(item => {
      try {
        const parsedItem = JSON.parse(item);
        if (typeof parsedItem === 'object') {
            result.body.push(parsedItem);
        } else {
            // 这里item可能会解析出number
            // 此时可以尝试重新用pako解压data(携带转换参数)
            // const newBody = textDecoder.decode(pako.inflate(data, {to: 'String'}))
            // 重复上面的逻辑,筛选可能存在的多条信息
            // 初步验证,这里可以解析到INTERACT_WORD、DANMU_MSG、ONLINE_RANK_COUNT
            // SEND_GIFT、SUPER_CHAT_MESSAGE
        }
      }
      catch(e) {
        // 忽略非 JSON 字符串,通常情况下为分隔符
      }
    });
}

Websocket API

你好,
根据 https://github.com/lovelyyoshino/Bilibili-Live-API/blob/master/API.WebSocket.md 实现了一个前端获取弹幕的工具,但是现在测试下来我有且只能获取到NOTICE_MSG类型的数据包(op==8和op==3同样会正常接收)。
this.$axios.get(/room/${this.roomid}).then((res) => { const userid = res.data.data.uid this.$axios.get(/danmuku_info/${this.roomid}).then((res) => { const data = res.data.data this.ws = new WebSocket('wss://broadcastlv.chat.bilibili.com/sub') this.ws.onopen = () => { this.ws.send(this.encode(JSON.stringify({ roomid: this.roomid, protover: 1, platform: 'web', type: 2, clientver: '2.4.16', key: data.token, uid: userid }), 7)) } this.ws.onclose = this.disconnect this.heartBeat = setInterval(() => { this.ws.send(this.encode('', 2)) }, 30000) this.ws.onmessage = this.onDanmaku this.busy = false }) })
后续我还根据ver分别decode body信息
if (result.ver === 2) { body = this.textDecoder.decode(pako.inflate(data)) if (body) { result.body.push(JSON.parse(body.slice(body.indexOf('{')))) } } else if (result.ver === 0) { body = this.textDecoder.decode(data) if (body) { result.body.push(JSON.parse(body)) } }
我目前完全无法获取其他类型的弹幕,是我哪里写错了还是b站又有了新的机制?

直播源获取

我看到了弹幕获取的api

但如果知道直播房间号码 想拿直播源的url 有没有哪个api能做到

补充:赠送包裹礼物的api

URL: http://api.live.bilibili.com/gift/v2/live/bag_send
Method: POST

Form Data:

uid:4726457           /* 赠送用户uid */
gift_id:1             /* 礼物id 1为辣条 */
ruid:28673629         /* 接收用户uid */
gift_num:2            /* 礼物数量 */
bag_id:67637286       /* 来源礼物包id */
platform:pc           /* 平台 */
biz_code:live         /*  */
biz_id:25886          /* 直播间号 */
rnd:1522516325        /* 当前时间戳 */
storm_beat_id:0       /* 连击数 默认 0 */
metadata:             /* 默认空 */
price:0               /* 默认为 0 ,免费的 */
csrf_token:fce9ff23db2a8da348172da7e8972020
                      /* 与 cookie 中 bili_jct 值一致 */

最新b站客户端播放记录获取方式

这是我从最新版客户端抓到的播放记录api
https://app.bilibili.com/x/v2/history/cursor?
改一个参数就可以获取到不同的数据类型(web端只有视频记录,无专栏,直播记录)
还需要一个cookie
sid | xxxxxxxx(不知道这个啥意思)

access_key | ac-key
appkey | app-key
build | 5370000
business | all all为全部,包含所有看过的视频+直播+专栏,其他参数为archive(视频),live(直播),article(专栏)
channel | bilibiil140
max | 0
max_tp | 0
mobi_app | android
platform | android
ps | 20
ts | 1549115009
sign |

视频连接失效了

本人小白 想通过fiddler来抓取视频连接 但是无法登录 无法加载页面 其他app倒是可以获取https链接
有大佬获取到视频的api可以分享一下的吗

想问一下b站直播websocket弹幕包编码问题

我用的是golang,能够连接到直播间获取弹幕包,根据api文档弹幕和各类广播数据是json格式传输,所以我用map[string]interface{}来接受,但是只能接受到广播信息,不能解析弹幕信息,想知道弹幕信息是不是进行了额外的编码或加密?

直播协议问题

这边收到了一个数据包,内容如下

00 00 00 14 00 10 00 00 00 00 00 03 00 00 00 00 00 05 76 B5

这是一个心跳响应包,但是其 protover 是 0(按照文档应是 1),并且 sequence id 是 0(文档中说固定为 1),不知文档是否需要更新

关于弹幕系统协议

一个数据包中有时候有多条弹幕消息,测试后我发现数据包长度就是整个帧的长度,而不是弹幕数据包的长度,所以无法通过offset来切割弹幕数据。是弹幕系统改了吗?

修改UserInfo.md文件名

目前项目里有两个同名文件
API.UserInfo.md
API.userinfo.md
在大小写不敏感的文件系统上无法共存
说的就是你Windows

话说有没有这样一个接口可以实现一键开播?

一般手动开播要进入直播设置,填写信息,点击开播,然后获取直播码。
类似直播姬的这种,有没有一个接口可以获取到,以实现自动式开播,而不需要每次推流都要上直播设置页面手动开启。

似乎有的直播间无法读取弹幕数据?

比如我用了这个直播间:923833
读取弹幕会一直报错(可能因为弹幕太多的原因?),说解析json失败,看了下错误是在下面这一行发出的:

          let body = textDecoder.decode(data);
          if(body){
            result.body.push(JSON.parse(body));  //这里报错
          }

看了下body的内容,发现body总是以x开头的乱码,也就是textDecoder.decode(data)不知道为什么失败了。是不是说有了新的编码方式?

补充一下...

小电视/舰长/pk 检测

https://api.live.bilibili.com/xlive/lottery-interface/v1/lottery/Check

字段 传递方式 类型 说明
roomid GET int 房间号

小电视/大楼等 抽奖

https://api.live.bilibili.com/xlive/lottery-interface/v5/smalltv/join

字段 传递方式 类型 说明
roomid POST int 房间号
id POST int 高能id
type POST string 类型 (guard之类的)
visit_id POST string [选填]
csrf POST string cookies之一
csrf_token POST string 与csrf相同

直播列表

https://api.live.bilibili.com/room/v3/area/getRoomList
希望有更完整的列表... 以这个为基础的舰长监听漏的太多了

字段 传递方式 类型 说明
parent_area_id GET int [0-6] (1-6对应区号,0为全站)
page GET int 页数
page_size GET int [1-99] 每页显示数量
sort_type GET string online

弹幕TCP协议

broadcastlv.chat.bilibili.com:2243
与WS的唯一区别只有不用Upgrade到WebSocket 心跳/推送请求一样的
稳定性不如WS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.