Skip to main content

No project description provided

Project description

B 站弹幕监听框架

特点

  • 简单,只需房间号即可监听
  • 异步,io 不阻塞,及时获取消息

B 站直播弹幕 websocket 协议分析

PROTOCOL 分析

快速开始

  1. 创建 app

    目前请克隆该代码仓库,并执行 pip install -r rquirements.txt

    from blive import  BLiver
    
    app = BLiver(123) #123为房间号
    
  2. 创建处理器

    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)
    
  3. 运行

    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


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.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blive-0.0.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file blive-0.0.1.tar.gz.

File metadata

  • Download URL: blive-0.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for blive-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c0161dd52d77b10f17ab5209127bfc8fcdcb614d5a6a1a799153e1cbf619d8c8
MD5 098bf32564814b56f160d100e2510e4e
BLAKE2b-256 07750fbe5c4ffe739644c676a7f8ca6c796e4db987d885530b8badce62c50836

See more details on using hashes here.

File details

Details for the file blive-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: blive-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for blive-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb21df7a34dc51eb59bf864a0e328618b6b840c3b65f09a876473e63d31f2cbf
MD5 73b8982e19bfc5c71077fbbb07a6b5b2
BLAKE2b-256 a6a58e5687268dfe226f93b8b450ebf2fd33a5ac06fb123261dda0b6c0bf88ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page