Skip to main content

A live danmu package

Project description

py2 py3 Chinese Version

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.


You may find document here.


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').

dmc = DanMuClient('')
if not dmc.isValid(): print('Url not valid')

def danmu_fn(msg):
    pp('[%s] %s' % (msg['NickName'], msg['Content']))
def gift_fn(msg):
    pp('[%s] sent a gift!' % msg['NickName'])

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('')

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('')


Q: What’s the message type of chat messages?

A: A dictionary with at least three keys, NickName, Content, MsgType.


If you have any problem or suggestion, feel free to contact me through this Issue.

Or through gitter: gitter

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

danmu-1.0.5.tar.gz (9.5 kB view hashes)

Uploaded source

Built Distribution

danmu-1.0.5-py2.py3-none-any.whl (16.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page