No project description provided
Project description
B 站弹幕监听框架
特点
- 简单,只需房间号即可监听
- 异步,io 不阻塞,及时获取消息
B 站直播弹幕 websocket 协议分析
快速开始
-
安装
pip install blive
-
创建 app
from blive import BLiver app = BLiver(123) #123为房间号
-
创建处理器
from blive import BLiver, Events, BLiverCtx app = BLiver(123) # 标记该方法监听弹幕消息,更多消息类型请参考 Events 类源代码 @app.on(Events.DANMU_MSG) async def listen_danmu(ctx: BLiverCtx): danmu = DanMuMsg(ctx.body) #ctx.body 套上相应的消息操作类即可得到消息的基本内容,也可直接操作 ctx.body print(danmu.content) print(danmu.sender) print(danmu.timestamp)
-
运行
from blive import BLiver, Events, BLiverCtx app = BLiver(123) @app.on(Events.DANMU_MSG) async def listen_danmu(ctx: BLiverCtx): danmu = DanMuMsg(ctx.body) print(danmu.content) print(danmu.sender) print(danmu.timestamp) app.run() # 运行app!
项目简介
- blive 文件夹为框架代码
- app.py 为一个简单示例
TODO
- 打包发布
- 更多的消息操作类
- 尝试加入中间件架构
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blive-0.0.4.tar.gz
(9.5 kB
view hashes)
Built Distribution
blive-0.0.4-py3-none-any.whl
(10.5 kB
view hashes)