pydouyu
斗鱼TV三方API、弹幕接口实现
Note
- 目前新的弹幕服务器域名切换到了
danmuproxy.douyu.com--2022.12.08 - 斗鱼官方提供的“openbarrage.douyutv.com”已经不维护,见issue#1,现在需要手动指定弹幕服务器ip来保持正常运行 --2020.07.08
Feature
- 官方已公布的斗鱼三方API完整实现
- 自动重连
- 稳定、无(少)数据遗漏
Install
pip3 install pydouyu
Example
from pydouyu.client import Client
import time
import sys
def chatmsg_handler(msg):
output = time.strftime("[%Y-%m-%d %H:%M:%S] ", time.localtime()) + msg['nn'] + ": " + msg['txt']
print(output)
sys.stdout.flush()
def uenter_handler(msg):
output = time.strftime("[%Y-%m-%d %H:%M:%S] ", time.localtime()) + msg['nn'] + " 进入了直播间"
print(output)
sys.stdout.flush()
c = Client(room_id=562590)
c.add_handler('chatmsg', chatmsg_handler)
c.add_handler('uenter', uenter_handler)
c.start()
Usage
- 运行 Demo
git clone https://github.com/Kexiii/pydouyu.gitcd pydouyupython3 example.py
- 二次开发
- 示例代码见 example.py
- 用户可以自定义handler函数,并且调用Client.add_handler注册
- Client.add_handler传入的第一个参数为消息类型,有哪些消息类型见下文弹幕协议
- msg是一个dict,其的各字段见下文中的弹幕协议
- 弹幕协议
Metadata
Release files for pydouyu 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydouyu-0.0.7.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydouyu-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / pydouyu-0.0.7.tar.gz
| Download URL | pydouyu-0.0.7.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7370ccbe532a1484ba2c361dc8017fca82dd2865a9f32ff8d7038565a24659e4
|
|
BLAKE2b-256 checksum How to use checksums |
d20b125e88c32dd67db0fae6bf480bbf752e1081e6269c7ab97132c2d267d9d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.8
|
Release files / pydouyu-0.0.7-py3-none-any.whl
| Download URL | pydouyu-0.0.7-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86e8d1a2013ce48b38275689e7cb51b6998edb21be0f4ad7b7e69ab46b5e9730
|
|
BLAKE2b-256 checksum How to use checksums |
e20d294323f3f7dda7bcba47f39414091c683bc88ab8088e51d65c3a465fdd4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.8
|