mirror of
https://github.com/xfgryujk/blivedm.git
synced 2025-01-13 13:50:25 +08:00
blivedm模块移到包内
This commit is contained in:
parent
4669b2c1c9
commit
0404f97134
11
README.md
11
README.md
@ -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
3
blivedm/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .blivedm import *
|
@ -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'
|
@ -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设为False,B站真的有过忘续证书的情况
|
||||
client = MyBLiveClient(room_id=21449083, ssl=True)
|
||||
future = client.start()
|
||||
try:
|
||||
# 5秒后停止,测试用
|
||||
# await asyncio.sleep(5)
|
||||
# future = client.stop()
|
||||
# 或者
|
||||
# future.cancel()
|
||||
|
||||
await future
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user