ANMU is an open-source live Platform Bullet screen interface, you can easily operate the platform with no foundation. With less than 30 lines of code, you can use Python to further develop based on the barrage. Support Fighting fish, Panda, Banner, Universal, Bilibili Multi-platform bomb screen. Support each version of Python, no platform-dependent, convenient for all types of developers, enthusiasts to use. Once opened, the host on-line automatic connection, offline after the online automatic re-connect.
A love bombing for a favorite host.
After the depth optimization, almost do not miss any of the barrage, using abstract architecture, easy to modify and develop.
Welcome to the ke Western python group :725479218, Welcome to JOIN!!!!!
Documents
You can get help using the website.
Installation
You can install DANMU with this command:
Pip Install Danmu
Simple uses
The following code allows you to initially process the barrage through Python.
import time, sysfrom danmuimport DanMuClientdef 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.danmudef danmu_fn(msg): pp(‘[%s] %s‘ % (msg[‘NickName‘], msg[‘Content‘]))@dmc.giftdef gift_fn(msg): pp(‘[%s] sent a gift!‘ % msg[‘NickName‘])@dmc.otherdef other_fn(msg): pp(‘Other message received‘)dmc.start(blockThread = True)
Screenshot
Advanced Uses
Set the default message handling method
Messages are divided into three types : Danmu, Gift, other
corresponding : Ordinary bullet screen, gift message, other messages
If a type is not registered, the default method is used, and the default method is registered as follows:
from danmu import DanMuClientdmc = DanMuClient(‘斗鱼网页‘)@dmc.defaultdef default_fn(msg): pp(‘[%s] %s‘ % (msg[‘NickName‘], msg[‘Content‘]))
Cancel a method that has already been registered
You can cancel a registration of one type in the following ways.
from danmu import DanMuClientdmc = DanMuClient(‘斗鱼网页‘)dmc.default(None)dmc.gift(None)
FAQs
Q: What are the message formats that are obtained?
A: The message is a dictionary, there must be three keys: nickname, Content, Msgtype, corresponding user name, message contents, message type.
Every big host is full screen barrage, how to do it? Python actual combat unlimited brush barrage!