Every big host is full screen barrage, how to do it? Python actual combat unlimited brush barrage!

Source: Internet
Author: User
Tags stdin

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.