blivedm模块移到包内

This commit is contained in:
John Smith 2021-12-12 19:28:12 +08:00
parent 4669b2c1c9
commit 0404f97134
4 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,5 @@
# blivedm
python3获取bilibili直播弹幕使用websocket协议
Python 3获取bilibili直播弹幕使用websocket协议
[协议解释](https://blog.csdn.net/xfgryujk/article/details/80306776)(有点过时了,总体是没错的)
@ -8,5 +7,9 @@ python3获取bilibili直播弹幕使用websocket协议
## 使用说明
1. 使用`pip install -r requirements.txt`命令安装依赖,具体有目录下[sample.py](./sample.py)和[blivedm.py](./blivedm.py)用到的相关python依赖
2. 将[sample.py](./sample.py)文件中的room_id替换为直播间ID
1. 需要Python 3.6及以上版本
2. 安装依赖
```sh
pip install -r requirements.txt
```
3. 例程看[sample.py](./sample.py)

3
blivedm/__init__.py Normal file
View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from .blivedm import *

View File

@ -12,7 +12,7 @@ from typing import *
import aiohttp
logger = logging.getLogger(__name__)
logger = logging.getLogger('blivedm')
ROOM_INIT_URL = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom'
DANMAKU_SERVER_CONF_URL = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo'

View File

@ -30,17 +30,14 @@ class MyBLiveClient(blivedm.BLiveClient):
async def main():
# 参数1是直播间ID
# 如果SSL验证失败就把ssl设为False
room_id = 14917277
client = MyBLiveClient(room_id, ssl=True)
# 直播间ID的取值看直播间URL
# 如果SSL验证失败就把ssl设为FalseB站真的有过忘续证书的情况
client = MyBLiveClient(room_id=21449083, ssl=True)
future = client.start()
try:
# 5秒后停止测试用
# await asyncio.sleep(5)
# future = client.stop()
# 或者
# future.cancel()
await future
finally: