danmu
danmu is Chinese translation of chat message.
It is an open source chat message api for live platforms like douyu, panda, huya, zhanqi.
Using this, even without programming basis, you will have an easy access to chat messages.
With less than 30 lines of code, you may develop further with chat messages.
Douyu, panda, Zhanqi, Quanmin, bilibili are all supported.
It supports multi versions of python and platforms, making it available for all developers and amateurs.
Once started, it will auto connect when anchor showed up and re-connect when anchor connect again.
With good optimization and abstract structure, almost all chat messages will be catched and the whole program is easy to be modified.
Documents
You may find document here.
Installation
You may use this script to install danmu:
pip install danmu
Simple uses
The following is a simple demo of how to use danmu.
import time, sys
from danmu import DanMuClient
def pp(msg):
print(msg.encode(sys.stdin.encoding, 'ignore').
decode(sys.stdin.encoding))
dmc = DanMuClient('http://www.douyu.com/lslalala')
if not dmc.isValid(): print('Url not valid')
@dmc.danmu
def danmu_fn(msg):
pp('[%s] %s' % (msg['NickName'], msg['Content']))
@dmc.gift
def gift_fn(msg):
pp('[%s] sent a gift!' % msg['NickName'])
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread = True)
Advanced uses
Set default chat message dealer
Messages are split into three types to be registered: danmu, gift, other.
Which means: ordinary chat messages, gift messages, other messages.
from danmu import DanMuClient
dmc = DanMuClient('http://www.douyu.com/lslalala')
@dmc.default
def default_fn(msg):
pp('[%s] %s' % (msg['NickName'], msg['Content']))
Cancel message dealer registered
Using the following codes, you can cancel a message dealer registered.
from danmu import DanMuClient
dmc = DanMuClient('http://www.douyu.com/lslalala')
dmc.default(None)
dmc.gift(None)
FAQ
Q: What’s the message type of chat messages?
A: A dictionary with at least three keys, NickName, Content, MsgType.
Comments
If you have any problem or suggestion, feel free to contact me through this Issue.
Metadata
Release files for danmu 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| danmu-1.0.5.tar.gz | 9.5 kB | Without provenance | Details for danmu-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| danmu-1.0.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for danmu-1.0.5-py2.py3-none-any.whl |
Total release size: 25.5 kB
Release files / danmu-1.0.5.tar.gz
| Download URL | danmu-1.0.5.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fa8bc8d6f1feeeb24c52fafd99e464f8f5b7872ba299f5cd674ae3bd6679ca7
|
|
BLAKE2b-256 checksum How to use checksums |
17d8697364c28dfbe8bcd5f2cadf6819e337662c3dcc6377a3ac2ec1beac03a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / danmu-1.0.5-py2.py3-none-any.whl
| Download URL | danmu-1.0.5-py2.py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a5d29f18952e4b75d00c1ddfa94b72da182525bb2979eae56e476dcd3d07ae76
|
|
BLAKE2b-256 checksum How to use checksums |
a3c7b242b3eb93136bbf07e0ea86395df73f5d600e94cac06b3f1ccd33bde821
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for danmu 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.