Comments (12)
@littleweb 代码不完整,建议补全
from danmu.
# -*- coding: UTF-8 -*-
import time, sys, requests
from danmu import DanMuClient
star_url = "http://www.douyu.com/wt55kai"
def pp(msg):
print(msg.encode(sys.stdin.encoding, 'ignore').
decode(sys.stdin.encoding))
sys.stdout.flush()
dmc = DanMuClient(star_url)
if not dmc.isValid(): print('Url not valid')
@dmc.danmu
def danmu_fn(msg):
payload = {
"star_id": "star_id",
"text": msg['Content'],
"type": "danmu",
"plat": "plat"
}
print payload
@dmc.gift
def gift_fn(msg):
pp('[%s] sent a gift!' % content['NickName'])
payload = {
"star_id": "star_id",
"text": msg['Content'],
"type": "danmu",
"plat": "plat"
}
print payload
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread = True)
from danmu.
@littleweb
我这里获取正常没有问题。
另,gift的Content键是没有内容的。
from danmu.
我把代码精简了下,还是只能打印出danmu,gift打印不出呢。
import time, sys, requests
from danmu import DanMuClient
star_url = "http://www.douyu.com/wt55kai"
dmc = DanMuClient(star_url)
if not dmc.isValid(): print('Url not valid')
@dmc.danmu
def danmu_fn(msg):
print "danmu";
@dmc.gift
def gift_fn(msg):
print "gift";
@dmc.other
def other_fn(msg):
print('Other message received')
dmc.start(blockThread=True)
from danmu.
- 你的danmu包版本是多少?
- 我这里能够获取说明协议没有问题
- 弹幕能获取说明通信与启动没有问题
- 建议抓个包看一下是否收到了弹幕的相关消息
from danmu.
OK了,应该是语法问题,多谢
礼物的数量有没有办法截获到呢
from danmu.
@littleweb
哪段代码的语法问题?我没有看出来
不同平台数量的算法不一样的,你可以获取整个消息体研究一下。
from danmu.
payload = {
"star_id": "star_id",
"text": msg['Content'],
"type": "danmu",
"plat": "plat"
}
print payload
我把这块封装了一下就好了
from danmu.
@littleweb
为什么封装一下就好了?
另,不是精简的代码也同样打不出来吗?
from danmu.
有可能调试的时候正好没有礼物吧
from danmu.
@littleweb
好的,那封装是指?
from danmu.
def save(type,text):
payload = {
"star_id": star_id,
"text": text,
"type": type,
"plat": plat
}
r = requests.get("http://localhost:9203/save", params=payload)
dmc = DanMuClient(star_url)
if not dmc.isValid(): print('Url not valid')
@dmc.danmu
def danmu_fn(msg):
save("danmu",msg['Content'])
pp('danmu')
@dmc.gift
def gift_fn(msg):
save("gift","")
pp('gift')
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread = True)
这样就可以了,很奇怪
from danmu.
Related Issues (20)
- Panda失效 HOT 26
- cannot import name 'DanMuClient' HOT 4
- 记录器失效 HOT 3
- pandatv 运行无反应
- 斗鱼弹幕部分失效 HOT 3
- HuomaoTV 失效求助 HOT 4
- b站失效了 HOT 4
- zhanqi.tv也失效了
- 淘宝直播的弹幕支持吗? HOT 1
- 可以发弹幕么?
- 大神,能不能写个虎牙的plugin
- 0000
- [bug]斗鱼礼物消息重复
- 其他平台实现问题
- __init__.py里面set_logging并未使用且会造成重复输出
- 不支持网易cc
- DouYu Danmu issue HOT 2
- 斗鱼收不到XXX欢迎来到本直播间的系统消息?
- 怎么停止正在爬取的弹幕操作
- 斗鱼新的url地址获取不到roomid
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from danmu.