Python implementation of douyu TV API
Project description
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,其的各字段见下文中的弹幕协议
- 弹幕协议
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
pydouyu-0.0.7.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydouyu-0.0.7.tar.gz.
File metadata
- Download URL: pydouyu-0.0.7.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7370ccbe532a1484ba2c361dc8017fca82dd2865a9f32ff8d7038565a24659e4
|
|
| MD5 |
bc158eb3c9b0a5a9887d8bef9d288e3e
|
|
| BLAKE2b-256 |
d20b125e88c32dd67db0fae6bf480bbf752e1081e6269c7ab97132c2d267d9d3
|
File details
Details for the file pydouyu-0.0.7-py3-none-any.whl.
File metadata
- Download URL: pydouyu-0.0.7-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86e8d1a2013ce48b38275689e7cb51b6998edb21be0f4ad7b7e69ab46b5e9730
|
|
| MD5 |
f46243b4b5a55e470b693ff353d53844
|
|
| BLAKE2b-256 |
e20d294323f3f7dda7bcba47f39414091c683bc88ab8088e51d65c3a465fdd4c
|