/bili-open-live-go

哔哩哔哩直播长连协议客户端 Golang 版本

Primary LanguageGoMIT LicenseMIT

bili-open-live-go

godoc

(非官方)基于哔哩哔哩官方开放平台 API实现的直播长连协议客户端 Golang 版本

这个项目还在施工中,API 随时可能发生变化,欢迎有动手能力的小伙伴体验,更欢迎一起共建完善造福社区

基本使用

你需要现在官方平台注册为开发者,并创建自己的应用,AppKey 和 AppSecret 通常和账号绑定,申请后官方会发送邮件给你, 如有疑问请联系官方客服~

Get it

在你的 Go 项目中安装依赖:

go get -u github.com/fython/bili-open-live-go

创建客户端

import biliopen "github.com/fython/bili-open-live-go"

client := &biliopen.LiveClient{
	AppKey:    yourAppKey,    // 申请得到的 App Key
	AppSecret: yourAppSecret, // 申请得到的 App Secret
	ProjectID: yourProjectID, // 应用项目 ID
}
client.OnDanmaku = func(dm biliopen.Danmaku) {
    log.Printf("收到弹幕:%+v", dm)
}

建立连接

ctx := context.Background()
if err := client.Connect(ctx, os.Getenv("LIVE_CODE")); err != nil {
	t.Fatal(err)
}

More

暂无文档,阅读 client_test.go 或源码定义了解更多用法

实现清单

  • 基本协议实现
  • 弹幕回调
  • 错误码文案 & 抓取脚本
  • 消息回调字段对齐官方版本 & 抓取版本
  • 服务端心跳包超时
  • 自动重连
  • Game API 完整实现(此项目主要是为了实现直播间长连协议,暂无计划支持)

Contacts

欢迎通过 Git Issues 或个人联系方式交流项目

Email: fythonx@gmail.com

Telegram: @fython

Licenses

MIT License

Copyright (c) 2023 Siubeng (fython)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.