哔哩哔哩直播间互动工具
Project description
哔哩哔哩直播间互动工具
特色
- 基于asyncio,可以满足更加丰富的使用场景
- 基于bilibili三代协议,支持brotli压缩算法,效率更高
安装
pip install bilibili-live
使用
首先创建事件处理器类,类需要继承BilibiliLiveEventHandler类,并重写需要监听的事件方法:
from bilibili_live.events import BilibiliLiveEventHandler, BilibiliLivePackage, Danmu
class MyEventHandler(BilibiliLiveEventHandler):
def onDanmu(self, package: BilibiliLivePackage, data: Danmu):
# do something
...
具体支持的事件可以参考BilibiliLiveEventHandler类
完成后,创建BilibiliLive对象,并启动监听:
from bilibili_live import BilibiliLive
room_id = 2411716
# 此处房间号为短号,即用户直接可见的房间号
bilibiliLive = BilibiliLive()
bilibiliLive.schedule(MyEventHandler(), room_id)
bilibiliLive.start()
需要退出时,可使用stop方法停止:
bilibiliLive.stop()
此时即开启了事件循环。此函数为异步(非阻塞函数)。
本模块基于asyncio设计。start函数为一个包装函数,其中创建了一个线程并包装了协程操作。如需要直接使用asyncio方式操作,可使用start_asyncio函数。
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
bilibili-live-0.1.1.tar.gz
(8.0 kB
view details)
Built Distribution
File details
Details for the file bilibili-live-0.1.1.tar.gz
.
File metadata
- Download URL: bilibili-live-0.1.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020d989e0889b141a40419444fa9e8c35e34e13c858131d8e480fde43ef2be70 |
|
MD5 | 2523136f4775ebf46ee91703e3aac9b5 |
|
BLAKE2b-256 | 5665702ebb8b1fa9c4ef4a2ef9cedf0443288911b6b094edabf5c179a2b689b5 |
File details
Details for the file bilibili_live-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: bilibili_live-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b72392410102094c5a4e89d1d7334bf170e7610f2ac750018739400fe20bc7ae |
|
MD5 | f76c81e1548e31b8c4cc5af5b6bc6be7 |
|
BLAKE2b-256 | 5fed95bf32672a1d752d715a37139c9b4508bcaadbb6ce2e8c23598c3b9ba13e |