Skip to main content

哔哩哔哩直播间互动工具

Project description

哔哩哔哩直播间互动工具

Author LICENSE python

特色

  • 基于asyncio,可以满足更加丰富的使用场景
  • 基于bilibili三代协议,支持brotli压缩算法,效率更高
  • 事件钩子部分使用泛型,开发更友好

安装

pip install bilibili-live

使用

首先创建事件处理器类,类需要继承BilibiliLiveEventHandler类,并重写需要监听的事件方法:

from bilibili_live.events import BilibiliLiveEventHandler, Danmu, Event

class MyEventHandler(BilibiliLiveEventHandler):
    def onDanmu(self, event: Event[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


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

Uploaded Source

Built Distribution

bilibili_live-0.8.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file bilibili-live-0.8.3.tar.gz.

File metadata

  • Download URL: bilibili-live-0.8.3.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for bilibili-live-0.8.3.tar.gz
Algorithm Hash digest
SHA256 122bb24b09a7f3da8e806f31a770d39b9302dff7ab59d35e0ebac28389b4bd5f
MD5 388339c3fd3b8eacdc514a1255325d13
BLAKE2b-256 2a5c73cace169e6f584d84ac4da3b701e3763fdce5980f19f12e20470da599a6

See more details on using hashes here.

File details

Details for the file bilibili_live-0.8.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bilibili_live-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dbefd7755b2cffd62ec1903b1e6bef2789ff12a1291a09116ae0bee0d113a5d5
MD5 953c2ae54a46249c6d4015427e36a0f9
BLAKE2b-256 ec0a4c98d7e2c6b1100dfe94dedb2ed69fafadf8fac96ad9072f16dee50f4778

See more details on using hashes here.

Supported by

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